1
2
3 package followschema
4
5 import (
6 "context"
7 "errors"
8 "fmt"
9 "strconv"
10 "sync/atomic"
11
12 "github.com/99designs/gqlgen/graphql"
13 "github.com/vektah/gqlparser/v2/ast"
14 )
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 func (ec *executionContext) _MapNested_value(ctx context.Context, field graphql.CollectedField, obj *MapNested) (ret graphql.Marshaler) {
31 fc, err := ec.fieldContext_MapNested_value(ctx, field)
32 if err != nil {
33 return graphql.Null
34 }
35 ctx = graphql.WithFieldContext(ctx, fc)
36 defer func() {
37 if r := recover(); r != nil {
38 ec.Error(ctx, ec.Recover(ctx, r))
39 ret = graphql.Null
40 }
41 }()
42 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
43 ctx = rctx
44 return obj.Value, nil
45 })
46
47 if resTmp == nil {
48 if !graphql.HasFieldError(ctx, fc) {
49 ec.Errorf(ctx, "must not be null")
50 }
51 return graphql.Null
52 }
53 res := resTmp.(CustomScalar)
54 fc.Result = res
55 return ec.marshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, field.Selections, res)
56 }
57
58 func (ec *executionContext) fieldContext_MapNested_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
59 fc = &graphql.FieldContext{
60 Object: "MapNested",
61 Field: field,
62 IsMethod: false,
63 IsResolver: false,
64 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
65 return nil, errors.New("field of type CustomScalar does not have child fields")
66 },
67 }
68 return fc, nil
69 }
70
71 func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) {
72 fc, err := ec.fieldContext_MapStringInterfaceType_a(ctx, field)
73 if err != nil {
74 return graphql.Null
75 }
76 ctx = graphql.WithFieldContext(ctx, fc)
77 defer func() {
78 if r := recover(); r != nil {
79 ec.Error(ctx, ec.Recover(ctx, r))
80 ret = graphql.Null
81 }
82 }()
83 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
84 ctx = rctx
85 switch v := obj["a"].(type) {
86 case *string:
87 return v, nil
88 case string:
89 return &v, nil
90 case nil:
91 return (*string)(nil), nil
92 default:
93 return nil, fmt.Errorf("unexpected type %T for field %s", v, "a")
94 }
95 })
96
97 if resTmp == nil {
98 return graphql.Null
99 }
100 res := resTmp.(*string)
101 fc.Result = res
102 return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
103 }
104
105 func (ec *executionContext) fieldContext_MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
106 fc = &graphql.FieldContext{
107 Object: "MapStringInterfaceType",
108 Field: field,
109 IsMethod: false,
110 IsResolver: false,
111 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
112 return nil, errors.New("field of type String does not have child fields")
113 },
114 }
115 return fc, nil
116 }
117
118 func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) {
119 fc, err := ec.fieldContext_MapStringInterfaceType_b(ctx, field)
120 if err != nil {
121 return graphql.Null
122 }
123 ctx = graphql.WithFieldContext(ctx, fc)
124 defer func() {
125 if r := recover(); r != nil {
126 ec.Error(ctx, ec.Recover(ctx, r))
127 ret = graphql.Null
128 }
129 }()
130 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
131 ctx = rctx
132 switch v := obj["b"].(type) {
133 case *int:
134 return v, nil
135 case int:
136 return &v, nil
137 case nil:
138 return (*int)(nil), nil
139 default:
140 return nil, fmt.Errorf("unexpected type %T for field %s", v, "b")
141 }
142 })
143
144 if resTmp == nil {
145 return graphql.Null
146 }
147 res := resTmp.(*int)
148 fc.Result = res
149 return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
150 }
151
152 func (ec *executionContext) fieldContext_MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
153 fc = &graphql.FieldContext{
154 Object: "MapStringInterfaceType",
155 Field: field,
156 IsMethod: false,
157 IsResolver: false,
158 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
159 return nil, errors.New("field of type Int does not have child fields")
160 },
161 }
162 return fc, nil
163 }
164
165 func (ec *executionContext) _MapStringInterfaceType_c(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) {
166 fc, err := ec.fieldContext_MapStringInterfaceType_c(ctx, field)
167 if err != nil {
168 return graphql.Null
169 }
170 ctx = graphql.WithFieldContext(ctx, fc)
171 defer func() {
172 if r := recover(); r != nil {
173 ec.Error(ctx, ec.Recover(ctx, r))
174 ret = graphql.Null
175 }
176 }()
177 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
178 ctx = rctx
179 switch v := obj["c"].(type) {
180 case *CustomScalar:
181 return v, nil
182 case CustomScalar:
183 return &v, nil
184 case nil:
185 return (*CustomScalar)(nil), nil
186 default:
187 return nil, fmt.Errorf("unexpected type %T for field %s", v, "c")
188 }
189 })
190
191 if resTmp == nil {
192 return graphql.Null
193 }
194 res := resTmp.(*CustomScalar)
195 fc.Result = res
196 return ec.marshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, field.Selections, res)
197 }
198
199 func (ec *executionContext) fieldContext_MapStringInterfaceType_c(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
200 fc = &graphql.FieldContext{
201 Object: "MapStringInterfaceType",
202 Field: field,
203 IsMethod: false,
204 IsResolver: false,
205 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
206 return nil, errors.New("field of type CustomScalar does not have child fields")
207 },
208 }
209 return fc, nil
210 }
211
212 func (ec *executionContext) _MapStringInterfaceType_nested(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) {
213 fc, err := ec.fieldContext_MapStringInterfaceType_nested(ctx, field)
214 if err != nil {
215 return graphql.Null
216 }
217 ctx = graphql.WithFieldContext(ctx, fc)
218 defer func() {
219 if r := recover(); r != nil {
220 ec.Error(ctx, ec.Recover(ctx, r))
221 ret = graphql.Null
222 }
223 }()
224 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
225 ctx = rctx
226 switch v := obj["nested"].(type) {
227 case *MapNested:
228 return v, nil
229 case MapNested:
230 return &v, nil
231 case nil:
232 return (*MapNested)(nil), nil
233 default:
234 return nil, fmt.Errorf("unexpected type %T for field %s", v, "nested")
235 }
236 })
237
238 if resTmp == nil {
239 return graphql.Null
240 }
241 res := resTmp.(*MapNested)
242 fc.Result = res
243 return ec.marshalOMapNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx, field.Selections, res)
244 }
245
246 func (ec *executionContext) fieldContext_MapStringInterfaceType_nested(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
247 fc = &graphql.FieldContext{
248 Object: "MapStringInterfaceType",
249 Field: field,
250 IsMethod: false,
251 IsResolver: false,
252 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
253 switch field.Name {
254 case "value":
255 return ec.fieldContext_MapNested_value(ctx, field)
256 }
257 return nil, fmt.Errorf("no field named %q was found under type MapNested", field.Name)
258 },
259 }
260 return fc, nil
261 }
262
263
264
265
266
267 func (ec *executionContext) unmarshalInputMapNestedInput(ctx context.Context, obj interface{}) (MapNested, error) {
268 var it MapNested
269 asMap := map[string]interface{}{}
270 for k, v := range obj.(map[string]interface{}) {
271 asMap[k] = v
272 }
273
274 fieldsInOrder := [...]string{"value"}
275 for _, k := range fieldsInOrder {
276 v, ok := asMap[k]
277 if !ok {
278 continue
279 }
280 switch k {
281 case "value":
282 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value"))
283 data, err := ec.unmarshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, v)
284 if err != nil {
285 return it, err
286 }
287 it.Value = data
288 }
289 }
290
291 return it, nil
292 }
293
294 func (ec *executionContext) unmarshalInputMapStringInterfaceInput(ctx context.Context, obj interface{}) (map[string]interface{}, error) {
295 it := make(map[string]interface{}, len(obj.(map[string]interface{})))
296 asMap := map[string]interface{}{}
297 for k, v := range obj.(map[string]interface{}) {
298 asMap[k] = v
299 }
300
301 fieldsInOrder := [...]string{"a", "b", "c", "nested"}
302 for _, k := range fieldsInOrder {
303 v, ok := asMap[k]
304 if !ok {
305 continue
306 }
307 switch k {
308 case "a":
309 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a"))
310 data, err := ec.unmarshalNString2string(ctx, v)
311 if err != nil {
312 return it, err
313 }
314 it["a"] = data
315 case "b":
316 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b"))
317 data, err := ec.unmarshalOInt2ᚖint(ctx, v)
318 if err != nil {
319 return it, err
320 }
321 it["b"] = data
322 case "c":
323 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("c"))
324 data, err := ec.unmarshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, v)
325 if err != nil {
326 return it, err
327 }
328 it["c"] = data
329 case "nested":
330 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nested"))
331 data, err := ec.unmarshalOMapNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx, v)
332 if err != nil {
333 return it, err
334 }
335 it["nested"] = data
336 }
337 }
338
339 return it, nil
340 }
341
342 func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, obj interface{}) (NestedMapInput, error) {
343 var it NestedMapInput
344 asMap := map[string]interface{}{}
345 for k, v := range obj.(map[string]interface{}) {
346 asMap[k] = v
347 }
348
349 fieldsInOrder := [...]string{"map"}
350 for _, k := range fieldsInOrder {
351 v, ok := asMap[k]
352 if !ok {
353 continue
354 }
355 switch k {
356 case "map":
357 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map"))
358 data, err := ec.unmarshalOMapStringInterfaceInput2map(ctx, v)
359 if err != nil {
360 return it, err
361 }
362 it.Map = data
363 }
364 }
365
366 return it, nil
367 }
368
369
370
371
372
373
374
375
376
377 var mapNestedImplementors = []string{"MapNested"}
378
379 func (ec *executionContext) _MapNested(ctx context.Context, sel ast.SelectionSet, obj *MapNested) graphql.Marshaler {
380 fields := graphql.CollectFields(ec.OperationContext, sel, mapNestedImplementors)
381
382 out := graphql.NewFieldSet(fields)
383 deferred := make(map[string]*graphql.FieldSet)
384 for i, field := range fields {
385 switch field.Name {
386 case "__typename":
387 out.Values[i] = graphql.MarshalString("MapNested")
388 case "value":
389 out.Values[i] = ec._MapNested_value(ctx, field, obj)
390 if out.Values[i] == graphql.Null {
391 out.Invalids++
392 }
393 default:
394 panic("unknown field " + strconv.Quote(field.Name))
395 }
396 }
397 out.Dispatch(ctx)
398 if out.Invalids > 0 {
399 return graphql.Null
400 }
401
402 atomic.AddInt32(&ec.deferred, int32(len(deferred)))
403
404 for label, dfs := range deferred {
405 ec.processDeferredGroup(graphql.DeferredGroup{
406 Label: label,
407 Path: graphql.GetPath(ctx),
408 FieldSet: dfs,
409 Context: ctx,
410 })
411 }
412
413 return out
414 }
415
416 var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"}
417
418 func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]interface{}) graphql.Marshaler {
419 fields := graphql.CollectFields(ec.OperationContext, sel, mapStringInterfaceTypeImplementors)
420
421 out := graphql.NewFieldSet(fields)
422 deferred := make(map[string]*graphql.FieldSet)
423 for i, field := range fields {
424 switch field.Name {
425 case "__typename":
426 out.Values[i] = graphql.MarshalString("MapStringInterfaceType")
427 case "a":
428 out.Values[i] = ec._MapStringInterfaceType_a(ctx, field, obj)
429 case "b":
430 out.Values[i] = ec._MapStringInterfaceType_b(ctx, field, obj)
431 case "c":
432 out.Values[i] = ec._MapStringInterfaceType_c(ctx, field, obj)
433 case "nested":
434 out.Values[i] = ec._MapStringInterfaceType_nested(ctx, field, obj)
435 default:
436 panic("unknown field " + strconv.Quote(field.Name))
437 }
438 }
439 out.Dispatch(ctx)
440 if out.Invalids > 0 {
441 return graphql.Null
442 }
443
444 atomic.AddInt32(&ec.deferred, int32(len(deferred)))
445
446 for label, dfs := range deferred {
447 ec.processDeferredGroup(graphql.DeferredGroup{
448 Label: label,
449 Path: graphql.GetPath(ctx),
450 FieldSet: dfs,
451 Context: ctx,
452 })
453 }
454
455 return out
456 }
457
458
459
460
461
462 func (ec *executionContext) unmarshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, v interface{}) (CustomScalar, error) {
463 var res CustomScalar
464 err := res.UnmarshalGQL(v)
465 return res, graphql.ErrorOnPath(ctx, err)
466 }
467
468 func (ec *executionContext) marshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v CustomScalar) graphql.Marshaler {
469 return v
470 }
471
472 func (ec *executionContext) unmarshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, v interface{}) (*CustomScalar, error) {
473 if v == nil {
474 return nil, nil
475 }
476 var res = new(CustomScalar)
477 err := res.UnmarshalGQL(v)
478 return res, graphql.ErrorOnPath(ctx, err)
479 }
480
481 func (ec *executionContext) marshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v *CustomScalar) graphql.Marshaler {
482 if v == nil {
483 return graphql.Null
484 }
485 return v
486 }
487
488 func (ec *executionContext) marshalOMapNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx context.Context, sel ast.SelectionSet, v *MapNested) graphql.Marshaler {
489 if v == nil {
490 return graphql.Null
491 }
492 return ec._MapNested(ctx, sel, v)
493 }
494
495 func (ec *executionContext) unmarshalOMapNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx context.Context, v interface{}) (*MapNested, error) {
496 if v == nil {
497 return nil, nil
498 }
499 res, err := ec.unmarshalInputMapNestedInput(ctx, v)
500 return &res, graphql.ErrorOnPath(ctx, err)
501 }
502
503 func (ec *executionContext) unmarshalOMapStringInterfaceInput2map(ctx context.Context, v interface{}) (map[string]interface{}, error) {
504 if v == nil {
505 return nil, nil
506 }
507 res, err := ec.unmarshalInputMapStringInterfaceInput(ctx, v)
508 return res, graphql.ErrorOnPath(ctx, err)
509 }
510
511 func (ec *executionContext) marshalOMapStringInterfaceType2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler {
512 if v == nil {
513 return graphql.Null
514 }
515 return ec._MapStringInterfaceType(ctx, sel, v)
516 }
517
518 func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedMapInput(ctx context.Context, v interface{}) (*NestedMapInput, error) {
519 if v == nil {
520 return nil, nil
521 }
522 res, err := ec.unmarshalInputNestedMapInput(ctx, v)
523 return &res, graphql.ErrorOnPath(ctx, err)
524 }
525
526
527
View as plain text