-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolver-federation.go
executable file
·68 lines (60 loc) · 1.65 KB
/
resolver-federation.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gen
import (
"context"
"fmt"
"github.com/99designs/gqlgen/graphql"
)
func (r *GeneratedQueryResolver) _service(ctx context.Context) (*_Service, error) {
sdl := SchemaSDL
return &_Service{
Sdl: &sdl,
}, nil
}
func getExecutionContext(ctx context.Context) executionContext {
e := ctx.Value(KeyExecutableSchema).(*executableSchema)
return executionContext{graphql.GetRequestContext(ctx), e}
}
func (r *GeneratedQueryResolver) _entities(ctx context.Context, representations []interface{}) (res []_Entity, err error) {
res = []_Entity{}
for _, repr := range representations {
anyValue, ok := repr.(map[string]interface{})
if !ok {
err = fmt.Errorf("The _entities resolver received invalid representation type")
break
}
typename, ok := anyValue["__typename"].(string)
if !ok {
err = fmt.Errorf("The _entities resolver received invalid representation type (missing __typename field)")
break
}
switch typename {
case "ConfiguratorItem":
ec := getExecutionContext(ctx)
f, _err := ec.unmarshalInputConfiguratorItemFilterType(ctx, anyValue)
err = _err
if err != nil {
return
}
if f.IsEmpty(ctx, r.GetDB(ctx).Dialect()) {
res = append(res, nil)
continue
}
item, _err := r.ConfiguratorItem(ctx, nil, nil, &f)
if _err != nil {
err = _err
return
}
if item == nil {
// append nil object without reflected interface
res = append(res, nil)
} else {
res = append(res, item)
}
break
default:
err = fmt.Errorf("The _entities resolver tried to load an entity for type \"%s\", but no object type of that name was found in the schema", typename)
return
}
}
return res, err
}