/
entity.resolvers.go
45 lines (37 loc) · 1.51 KB
/
entity.resolvers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package graph
// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen version v0.17.20-dev DO NOT EDIT.
import (
"context"
"github.com/99designs/gqlgen/_examples/federation/products/graph/generated"
"github.com/99designs/gqlgen/_examples/federation/products/graph/model"
)
// FindManufacturerByID is the resolver for the findManufacturerByID field.
func (r *entityResolver) FindManufacturerByID(ctx context.Context, id string) (*model.Manufacturer, error) {
return &model.Manufacturer{
ID: id,
Name: "Millinery " + id,
}, nil
}
// FindProductByManufacturerIDAndID is the resolver for the findProductByManufacturerIDAndID field.
func (r *entityResolver) FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error) {
for _, hat := range hats {
if hat.ID == id && hat.Manufacturer.ID == manufacturerID {
return hat, nil
}
}
return nil, nil
}
// FindProductByUpc is the resolver for the findProductByUpc field.
func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) {
for _, hat := range hats {
if hat.Upc == upc {
return hat, nil
}
}
return nil, nil
}
// Entity returns generated.EntityResolver implementation.
func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} }
type entityResolver struct{ *Resolver }