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