1{{- range $object := .Objects }}
2
3var {{ $object.Name|lcFirst}}Implementors = {{$object.Implementors}}
4
5{{- if .Stream }}
6func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {
7 fields := graphql.CollectFields(ctx, sel, {{$object.Name|lcFirst}}Implementors)
8 ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{
9 Object: {{$object.Name|quote}},
10 })
11 if len(fields) != 1 {
12 ec.Errorf(ctx, "must subscribe to exactly one stream")
13 return nil
14 }
15
16 switch fields[0].Name {
17 {{- range $field := $object.Fields }}
18 case "{{$field.Name}}":
19 return ec._{{$object.Name}}_{{$field.Name}}(ctx, fields[0])
20 {{- end }}
21 default:
22 panic("unknown field " + strconv.Quote(fields[0].Name))
23 }
24}
25{{- else }}
26func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet{{ if not $object.Root }},obj {{$object.Reference | ref }}{{ end }}) graphql.Marshaler {
27 fields := graphql.CollectFields(ctx, sel, {{$object.Name|lcFirst}}Implementors)
28 {{if $object.Root}}
29 ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{
30 Object: {{$object.Name|quote}},
31 })
32 {{end}}
33
34 out := graphql.NewFieldSet(fields)
35 invalid := false
36 for i, field := range fields {
37 switch field.Name {
38 case "__typename":
39 out.Values[i] = graphql.MarshalString({{$object.Name|quote}})
40 {{- range $field := $object.Fields }}
41 case "{{$field.Name}}":
42 {{- if $field.IsConcurrent }}
43 field := field
44 out.Concurrently(i, func() (res graphql.Marshaler) {
45 defer func() {
46 if r := recover(); r != nil {
47 ec.Error(ctx, ec.Recover(ctx, r))
48 }
49 }()
50 res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}})
51 {{- if $field.TypeReference.GQL.NonNull }}
52 if res == graphql.Null {
53 invalid = true
54 }
55 {{- end }}
56 return res
57 })
58 {{- else }}
59 out.Values[i] = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}})
60 {{- if $field.TypeReference.GQL.NonNull }}
61 if out.Values[i] == graphql.Null {
62 invalid = true
63 }
64 {{- end }}
65 {{- end }}
66 {{- end }}
67 default:
68 panic("unknown field " + strconv.Quote(field.Name))
69 }
70 }
71 out.Dispatch()
72 if invalid { return graphql.Null }
73 return out
74}
75{{- end }}
76
77{{- end }}