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 type MutationResolver interface {
19 DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error)
20 OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error)
21 UpdateSomething(ctx context.Context, input SpecialInput) (string, error)
22 UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error)
23 }
24
25
26
27
28
29 func (ec *executionContext) field_Mutation_defaultInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
30 var err error
31 args := map[string]interface{}{}
32 var arg0 DefaultInput
33 if tmp, ok := rawArgs["input"]; ok {
34 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
35 arg0, err = ec.unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx, tmp)
36 if err != nil {
37 return nil, err
38 }
39 }
40 args["input"] = arg0
41 return args, nil
42 }
43
44 func (ec *executionContext) field_Mutation_overrideValueViaInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
45 var err error
46 args := map[string]interface{}{}
47 var arg0 FieldsOrderInput
48 if tmp, ok := rawArgs["input"]; ok {
49 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
50 arg0, err = ec.unmarshalNFieldsOrderInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderInput(ctx, tmp)
51 if err != nil {
52 return nil, err
53 }
54 }
55 args["input"] = arg0
56 return args, nil
57 }
58
59 func (ec *executionContext) field_Mutation_updatePtrToPtr_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
60 var err error
61 args := map[string]interface{}{}
62 var arg0 UpdatePtrToPtrOuter
63 if tmp, ok := rawArgs["input"]; ok {
64 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
65 arg0, err = ec.unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrOuter(ctx, tmp)
66 if err != nil {
67 return nil, err
68 }
69 }
70 args["input"] = arg0
71 return args, nil
72 }
73
74 func (ec *executionContext) field_Mutation_updateSomething_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
75 var err error
76 args := map[string]interface{}{}
77 var arg0 SpecialInput
78 if tmp, ok := rawArgs["input"]; ok {
79 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
80 arg0, err = ec.unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSpecialInput(ctx, tmp)
81 if err != nil {
82 return nil, err
83 }
84 }
85 args["input"] = arg0
86 return args, nil
87 }
88
89
90
91
92
93
94
95
96
97 func (ec *executionContext) _DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) {
98 fc, err := ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field)
99 if err != nil {
100 return graphql.Null
101 }
102 ctx = graphql.WithFieldContext(ctx, fc)
103 defer func() {
104 if r := recover(); r != nil {
105 ec.Error(ctx, ec.Recover(ctx, r))
106 ret = graphql.Null
107 }
108 }()
109 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
110 ctx = rctx
111 return obj.FalsyBoolean, nil
112 })
113
114 if resTmp == nil {
115 return graphql.Null
116 }
117 res := resTmp.(*bool)
118 fc.Result = res
119 return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
120 }
121
122 func (ec *executionContext) fieldContext_DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
123 fc = &graphql.FieldContext{
124 Object: "DefaultParametersMirror",
125 Field: field,
126 IsMethod: false,
127 IsResolver: false,
128 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
129 return nil, errors.New("field of type Boolean does not have child fields")
130 },
131 }
132 return fc, nil
133 }
134
135 func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) {
136 fc, err := ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field)
137 if err != nil {
138 return graphql.Null
139 }
140 ctx = graphql.WithFieldContext(ctx, fc)
141 defer func() {
142 if r := recover(); r != nil {
143 ec.Error(ctx, ec.Recover(ctx, r))
144 ret = graphql.Null
145 }
146 }()
147 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
148 ctx = rctx
149 return obj.TruthyBoolean, nil
150 })
151
152 if resTmp == nil {
153 return graphql.Null
154 }
155 res := resTmp.(*bool)
156 fc.Result = res
157 return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
158 }
159
160 func (ec *executionContext) fieldContext_DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
161 fc = &graphql.FieldContext{
162 Object: "DefaultParametersMirror",
163 Field: field,
164 IsMethod: false,
165 IsResolver: false,
166 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
167 return nil, errors.New("field of type Boolean does not have child fields")
168 },
169 }
170 return fc, nil
171 }
172
173 func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
174 fc, err := ec.fieldContext_Mutation_defaultInput(ctx, field)
175 if err != nil {
176 return graphql.Null
177 }
178 ctx = graphql.WithFieldContext(ctx, fc)
179 defer func() {
180 if r := recover(); r != nil {
181 ec.Error(ctx, ec.Recover(ctx, r))
182 ret = graphql.Null
183 }
184 }()
185 resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
186 ctx = rctx
187 return ec.resolvers.Mutation().DefaultInput(rctx, fc.Args["input"].(DefaultInput))
188 })
189
190 if resTmp == nil {
191 if !graphql.HasFieldError(ctx, fc) {
192 ec.Errorf(ctx, "must not be null")
193 }
194 return graphql.Null
195 }
196 res := resTmp.(*DefaultParametersMirror)
197 fc.Result = res
198 return ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx, field.Selections, res)
199 }
200
201 func (ec *executionContext) fieldContext_Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
202 fc = &graphql.FieldContext{
203 Object: "Mutation",
204 Field: field,
205 IsMethod: true,
206 IsResolver: true,
207 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
208 switch field.Name {
209 case "falsyBoolean":
210 return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field)
211 case "truthyBoolean":
212 return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field)
213 }
214 return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name)
215 },
216 }
217 defer func() {
218 if r := recover(); r != nil {
219 err = ec.Recover(ctx, r)
220 ec.Error(ctx, err)
221 }
222 }()
223 ctx = graphql.WithFieldContext(ctx, fc)
224 if fc.Args, err = ec.field_Mutation_defaultInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
225 ec.Error(ctx, err)
226 return fc, err
227 }
228 return fc, nil
229 }
230
231 func (ec *executionContext) _Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
232 fc, err := ec.fieldContext_Mutation_overrideValueViaInput(ctx, field)
233 if err != nil {
234 return graphql.Null
235 }
236 ctx = graphql.WithFieldContext(ctx, fc)
237 defer func() {
238 if r := recover(); r != nil {
239 ec.Error(ctx, ec.Recover(ctx, r))
240 ret = graphql.Null
241 }
242 }()
243 resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
244 ctx = rctx
245 return ec.resolvers.Mutation().OverrideValueViaInput(rctx, fc.Args["input"].(FieldsOrderInput))
246 })
247
248 if resTmp == nil {
249 if !graphql.HasFieldError(ctx, fc) {
250 ec.Errorf(ctx, "must not be null")
251 }
252 return graphql.Null
253 }
254 res := resTmp.(*FieldsOrderPayload)
255 fc.Result = res
256 return ec.marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx, field.Selections, res)
257 }
258
259 func (ec *executionContext) fieldContext_Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
260 fc = &graphql.FieldContext{
261 Object: "Mutation",
262 Field: field,
263 IsMethod: true,
264 IsResolver: true,
265 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
266 switch field.Name {
267 case "firstFieldValue":
268 return ec.fieldContext_FieldsOrderPayload_firstFieldValue(ctx, field)
269 }
270 return nil, fmt.Errorf("no field named %q was found under type FieldsOrderPayload", field.Name)
271 },
272 }
273 defer func() {
274 if r := recover(); r != nil {
275 err = ec.Recover(ctx, r)
276 ec.Error(ctx, err)
277 }
278 }()
279 ctx = graphql.WithFieldContext(ctx, fc)
280 if fc.Args, err = ec.field_Mutation_overrideValueViaInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
281 ec.Error(ctx, err)
282 return fc, err
283 }
284 return fc, nil
285 }
286
287 func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
288 fc, err := ec.fieldContext_Mutation_updateSomething(ctx, field)
289 if err != nil {
290 return graphql.Null
291 }
292 ctx = graphql.WithFieldContext(ctx, fc)
293 defer func() {
294 if r := recover(); r != nil {
295 ec.Error(ctx, ec.Recover(ctx, r))
296 ret = graphql.Null
297 }
298 }()
299 resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
300 ctx = rctx
301 return ec.resolvers.Mutation().UpdateSomething(rctx, fc.Args["input"].(SpecialInput))
302 })
303
304 if resTmp == nil {
305 if !graphql.HasFieldError(ctx, fc) {
306 ec.Errorf(ctx, "must not be null")
307 }
308 return graphql.Null
309 }
310 res := resTmp.(string)
311 fc.Result = res
312 return ec.marshalNString2string(ctx, field.Selections, res)
313 }
314
315 func (ec *executionContext) fieldContext_Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
316 fc = &graphql.FieldContext{
317 Object: "Mutation",
318 Field: field,
319 IsMethod: true,
320 IsResolver: true,
321 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
322 return nil, errors.New("field of type String does not have child fields")
323 },
324 }
325 defer func() {
326 if r := recover(); r != nil {
327 err = ec.Recover(ctx, r)
328 ec.Error(ctx, err)
329 }
330 }()
331 ctx = graphql.WithFieldContext(ctx, fc)
332 if fc.Args, err = ec.field_Mutation_updateSomething_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
333 ec.Error(ctx, err)
334 return fc, err
335 }
336 return fc, nil
337 }
338
339 func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
340 fc, err := ec.fieldContext_Mutation_updatePtrToPtr(ctx, field)
341 if err != nil {
342 return graphql.Null
343 }
344 ctx = graphql.WithFieldContext(ctx, fc)
345 defer func() {
346 if r := recover(); r != nil {
347 ec.Error(ctx, ec.Recover(ctx, r))
348 ret = graphql.Null
349 }
350 }()
351 resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
352 ctx = rctx
353 return ec.resolvers.Mutation().UpdatePtrToPtr(rctx, fc.Args["input"].(UpdatePtrToPtrOuter))
354 })
355
356 if resTmp == nil {
357 if !graphql.HasFieldError(ctx, fc) {
358 ec.Errorf(ctx, "must not be null")
359 }
360 return graphql.Null
361 }
362 res := resTmp.(*PtrToPtrOuter)
363 fc.Result = res
364 return ec.marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx, field.Selections, res)
365 }
366
367 func (ec *executionContext) fieldContext_Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
368 fc = &graphql.FieldContext{
369 Object: "Mutation",
370 Field: field,
371 IsMethod: true,
372 IsResolver: true,
373 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
374 switch field.Name {
375 case "name":
376 return ec.fieldContext_PtrToPtrOuter_name(ctx, field)
377 case "inner":
378 return ec.fieldContext_PtrToPtrOuter_inner(ctx, field)
379 case "stupidInner":
380 return ec.fieldContext_PtrToPtrOuter_stupidInner(ctx, field)
381 }
382 return nil, fmt.Errorf("no field named %q was found under type PtrToPtrOuter", field.Name)
383 },
384 }
385 defer func() {
386 if r := recover(); r != nil {
387 err = ec.Recover(ctx, r)
388 ec.Error(ctx, err)
389 }
390 }()
391 ctx = graphql.WithFieldContext(ctx, fc)
392 if fc.Args, err = ec.field_Mutation_updatePtrToPtr_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
393 ec.Error(ctx, err)
394 return fc, err
395 }
396 return fc, nil
397 }
398
399
400
401
402
403 func (ec *executionContext) unmarshalInputDefaultInput(ctx context.Context, obj interface{}) (DefaultInput, error) {
404 var it DefaultInput
405 asMap := map[string]interface{}{}
406 for k, v := range obj.(map[string]interface{}) {
407 asMap[k] = v
408 }
409
410 if _, present := asMap["falsyBoolean"]; !present {
411 asMap["falsyBoolean"] = false
412 }
413 if _, present := asMap["truthyBoolean"]; !present {
414 asMap["truthyBoolean"] = true
415 }
416
417 fieldsInOrder := [...]string{"falsyBoolean", "truthyBoolean"}
418 for _, k := range fieldsInOrder {
419 v, ok := asMap[k]
420 if !ok {
421 continue
422 }
423 switch k {
424 case "falsyBoolean":
425 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean"))
426 data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v)
427 if err != nil {
428 return it, err
429 }
430 it.FalsyBoolean = data
431 case "truthyBoolean":
432 ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean"))
433 data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v)
434 if err != nil {
435 return it, err
436 }
437 it.TruthyBoolean = data
438 }
439 }
440
441 return it, nil
442 }
443
444
445
446
447
448
449
450
451
452 var defaultParametersMirrorImplementors = []string{"DefaultParametersMirror"}
453
454 func (ec *executionContext) _DefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, obj *DefaultParametersMirror) graphql.Marshaler {
455 fields := graphql.CollectFields(ec.OperationContext, sel, defaultParametersMirrorImplementors)
456
457 out := graphql.NewFieldSet(fields)
458 deferred := make(map[string]*graphql.FieldSet)
459 for i, field := range fields {
460 switch field.Name {
461 case "__typename":
462 out.Values[i] = graphql.MarshalString("DefaultParametersMirror")
463 case "falsyBoolean":
464 out.Values[i] = ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj)
465 case "truthyBoolean":
466 out.Values[i] = ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj)
467 default:
468 panic("unknown field " + strconv.Quote(field.Name))
469 }
470 }
471 out.Dispatch(ctx)
472 if out.Invalids > 0 {
473 return graphql.Null
474 }
475
476 atomic.AddInt32(&ec.deferred, int32(len(deferred)))
477
478 for label, dfs := range deferred {
479 ec.processDeferredGroup(graphql.DeferredGroup{
480 Label: label,
481 Path: graphql.GetPath(ctx),
482 FieldSet: dfs,
483 Context: ctx,
484 })
485 }
486
487 return out
488 }
489
490 var mutationImplementors = []string{"Mutation"}
491
492 func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
493 fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors)
494 ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
495 Object: "Mutation",
496 })
497
498 out := graphql.NewFieldSet(fields)
499 deferred := make(map[string]*graphql.FieldSet)
500 for i, field := range fields {
501 innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
502 Object: field.Name,
503 Field: field,
504 })
505
506 switch field.Name {
507 case "__typename":
508 out.Values[i] = graphql.MarshalString("Mutation")
509 case "defaultInput":
510 out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
511 return ec._Mutation_defaultInput(ctx, field)
512 })
513 if out.Values[i] == graphql.Null {
514 out.Invalids++
515 }
516 case "overrideValueViaInput":
517 out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
518 return ec._Mutation_overrideValueViaInput(ctx, field)
519 })
520 if out.Values[i] == graphql.Null {
521 out.Invalids++
522 }
523 case "updateSomething":
524 out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
525 return ec._Mutation_updateSomething(ctx, field)
526 })
527 if out.Values[i] == graphql.Null {
528 out.Invalids++
529 }
530 case "updatePtrToPtr":
531 out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
532 return ec._Mutation_updatePtrToPtr(ctx, field)
533 })
534 if out.Values[i] == graphql.Null {
535 out.Invalids++
536 }
537 default:
538 panic("unknown field " + strconv.Quote(field.Name))
539 }
540 }
541 out.Dispatch(ctx)
542 if out.Invalids > 0 {
543 return graphql.Null
544 }
545
546 atomic.AddInt32(&ec.deferred, int32(len(deferred)))
547
548 for label, dfs := range deferred {
549 ec.processDeferredGroup(graphql.DeferredGroup{
550 Label: label,
551 Path: graphql.GetPath(ctx),
552 FieldSet: dfs,
553 Context: ctx,
554 })
555 }
556
557 return out
558 }
559
560
561
562
563
564 func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx context.Context, v interface{}) (DefaultInput, error) {
565 res, err := ec.unmarshalInputDefaultInput(ctx, v)
566 return res, graphql.ErrorOnPath(ctx, err)
567 }
568
569 func (ec *executionContext) marshalNDefaultParametersMirror2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v DefaultParametersMirror) graphql.Marshaler {
570 return ec._DefaultParametersMirror(ctx, sel, &v)
571 }
572
573 func (ec *executionContext) marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v *DefaultParametersMirror) graphql.Marshaler {
574 if v == nil {
575 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
576 ec.Errorf(ctx, "the requested element is null which the schema does not allow")
577 }
578 return graphql.Null
579 }
580 return ec._DefaultParametersMirror(ctx, sel, v)
581 }
582
583
584
View as plain text