github.com/matiasanaya/gqlgen@v0.6.0/example/config/generated.go (about) 1 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 3 package config 4 5 import ( 6 bytes "bytes" 7 context "context" 8 strconv "strconv" 9 sync "sync" 10 11 graphql "github.com/99designs/gqlgen/graphql" 12 introspection "github.com/99designs/gqlgen/graphql/introspection" 13 gqlparser "github.com/vektah/gqlparser" 14 ast "github.com/vektah/gqlparser/ast" 15 ) 16 17 // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. 18 func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { 19 return &executableSchema{ 20 resolvers: cfg.Resolvers, 21 directives: cfg.Directives, 22 complexity: cfg.Complexity, 23 } 24 } 25 26 type Config struct { 27 Resolvers ResolverRoot 28 Directives DirectiveRoot 29 Complexity ComplexityRoot 30 } 31 32 type ResolverRoot interface { 33 Mutation() MutationResolver 34 Query() QueryResolver 35 Todo() TodoResolver 36 } 37 38 type DirectiveRoot struct { 39 } 40 41 type ComplexityRoot struct { 42 Mutation struct { 43 CreateTodo func(childComplexity int, input NewTodo) int 44 } 45 46 Query struct { 47 Todos func(childComplexity int) int 48 } 49 50 Todo struct { 51 Id func(childComplexity int) int 52 DatabaseId func(childComplexity int) int 53 Text func(childComplexity int) int 54 Done func(childComplexity int) int 55 User func(childComplexity int) int 56 } 57 58 User struct { 59 Id func(childComplexity int) int 60 Name func(childComplexity int) int 61 } 62 } 63 64 type MutationResolver interface { 65 CreateTodo(ctx context.Context, input NewTodo) (Todo, error) 66 } 67 type QueryResolver interface { 68 Todos(ctx context.Context) ([]Todo, error) 69 } 70 type TodoResolver interface { 71 ID(ctx context.Context, obj *Todo) (string, error) 72 } 73 74 func field_Mutation_createTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { 75 args := map[string]interface{}{} 76 var arg0 NewTodo 77 if tmp, ok := rawArgs["input"]; ok { 78 var err error 79 arg0, err = UnmarshalNewTodo(tmp) 80 if err != nil { 81 return nil, err 82 } 83 } 84 args["input"] = arg0 85 return args, nil 86 87 } 88 89 func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { 90 args := map[string]interface{}{} 91 var arg0 string 92 if tmp, ok := rawArgs["name"]; ok { 93 var err error 94 arg0, err = graphql.UnmarshalString(tmp) 95 if err != nil { 96 return nil, err 97 } 98 } 99 args["name"] = arg0 100 return args, nil 101 102 } 103 104 func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { 105 args := map[string]interface{}{} 106 var arg0 bool 107 if tmp, ok := rawArgs["includeDeprecated"]; ok { 108 var err error 109 arg0, err = graphql.UnmarshalBoolean(tmp) 110 if err != nil { 111 return nil, err 112 } 113 } 114 args["includeDeprecated"] = arg0 115 return args, nil 116 117 } 118 119 func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { 120 args := map[string]interface{}{} 121 var arg0 bool 122 if tmp, ok := rawArgs["includeDeprecated"]; ok { 123 var err error 124 arg0, err = graphql.UnmarshalBoolean(tmp) 125 if err != nil { 126 return nil, err 127 } 128 } 129 args["includeDeprecated"] = arg0 130 return args, nil 131 132 } 133 134 type executableSchema struct { 135 resolvers ResolverRoot 136 directives DirectiveRoot 137 complexity ComplexityRoot 138 } 139 140 func (e *executableSchema) Schema() *ast.Schema { 141 return parsedSchema 142 } 143 144 func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { 145 switch typeName + "." + field { 146 147 case "Mutation.createTodo": 148 if e.complexity.Mutation.CreateTodo == nil { 149 break 150 } 151 152 args, err := field_Mutation_createTodo_args(rawArgs) 153 if err != nil { 154 return 0, false 155 } 156 157 return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true 158 159 case "Query.todos": 160 if e.complexity.Query.Todos == nil { 161 break 162 } 163 164 return e.complexity.Query.Todos(childComplexity), true 165 166 case "Todo.id": 167 if e.complexity.Todo.Id == nil { 168 break 169 } 170 171 return e.complexity.Todo.Id(childComplexity), true 172 173 case "Todo.databaseId": 174 if e.complexity.Todo.DatabaseId == nil { 175 break 176 } 177 178 return e.complexity.Todo.DatabaseId(childComplexity), true 179 180 case "Todo.text": 181 if e.complexity.Todo.Text == nil { 182 break 183 } 184 185 return e.complexity.Todo.Text(childComplexity), true 186 187 case "Todo.done": 188 if e.complexity.Todo.Done == nil { 189 break 190 } 191 192 return e.complexity.Todo.Done(childComplexity), true 193 194 case "Todo.user": 195 if e.complexity.Todo.User == nil { 196 break 197 } 198 199 return e.complexity.Todo.User(childComplexity), true 200 201 case "User.id": 202 if e.complexity.User.Id == nil { 203 break 204 } 205 206 return e.complexity.User.Id(childComplexity), true 207 208 case "User.name": 209 if e.complexity.User.Name == nil { 210 break 211 } 212 213 return e.complexity.User.Name(childComplexity), true 214 215 } 216 return 0, false 217 } 218 219 func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { 220 ec := executionContext{graphql.GetRequestContext(ctx), e} 221 222 buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { 223 data := ec._Query(ctx, op.SelectionSet) 224 var buf bytes.Buffer 225 data.MarshalGQL(&buf) 226 return buf.Bytes() 227 }) 228 229 return &graphql.Response{ 230 Data: buf, 231 Errors: ec.Errors, 232 Extensions: ec.Extensions} 233 } 234 235 func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { 236 ec := executionContext{graphql.GetRequestContext(ctx), e} 237 238 buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { 239 data := ec._Mutation(ctx, op.SelectionSet) 240 var buf bytes.Buffer 241 data.MarshalGQL(&buf) 242 return buf.Bytes() 243 }) 244 245 return &graphql.Response{ 246 Data: buf, 247 Errors: ec.Errors, 248 Extensions: ec.Extensions, 249 } 250 } 251 252 func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { 253 return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) 254 } 255 256 type executionContext struct { 257 *graphql.RequestContext 258 *executableSchema 259 } 260 261 var mutationImplementors = []string{"Mutation"} 262 263 // nolint: gocyclo, errcheck, gas, goconst 264 func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 265 fields := graphql.CollectFields(ctx, sel, mutationImplementors) 266 267 ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ 268 Object: "Mutation", 269 }) 270 271 out := graphql.NewOrderedMap(len(fields)) 272 invalid := false 273 for i, field := range fields { 274 out.Keys[i] = field.Alias 275 276 switch field.Name { 277 case "__typename": 278 out.Values[i] = graphql.MarshalString("Mutation") 279 case "createTodo": 280 out.Values[i] = ec._Mutation_createTodo(ctx, field) 281 if out.Values[i] == graphql.Null { 282 invalid = true 283 } 284 default: 285 panic("unknown field " + strconv.Quote(field.Name)) 286 } 287 } 288 289 if invalid { 290 return graphql.Null 291 } 292 return out 293 } 294 295 // nolint: vetshadow 296 func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { 297 rawArgs := field.ArgumentMap(ec.Variables) 298 args, err := field_Mutation_createTodo_args(rawArgs) 299 if err != nil { 300 ec.Error(ctx, err) 301 return graphql.Null 302 } 303 rctx := &graphql.ResolverContext{ 304 Object: "Mutation", 305 Args: args, 306 Field: field, 307 } 308 ctx = graphql.WithResolverContext(ctx, rctx) 309 resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { 310 ctx = rctx // use context from middleware stack in children 311 return ec.resolvers.Mutation().CreateTodo(rctx, args["input"].(NewTodo)) 312 }) 313 if resTmp == nil { 314 if !ec.HasError(rctx) { 315 ec.Errorf(ctx, "must not be null") 316 } 317 return graphql.Null 318 } 319 res := resTmp.(Todo) 320 rctx.Result = res 321 322 return ec._Todo(ctx, field.Selections, &res) 323 } 324 325 var queryImplementors = []string{"Query"} 326 327 // nolint: gocyclo, errcheck, gas, goconst 328 func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { 329 fields := graphql.CollectFields(ctx, sel, queryImplementors) 330 331 ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ 332 Object: "Query", 333 }) 334 335 var wg sync.WaitGroup 336 out := graphql.NewOrderedMap(len(fields)) 337 invalid := false 338 for i, field := range fields { 339 out.Keys[i] = field.Alias 340 341 switch field.Name { 342 case "__typename": 343 out.Values[i] = graphql.MarshalString("Query") 344 case "todos": 345 wg.Add(1) 346 go func(i int, field graphql.CollectedField) { 347 out.Values[i] = ec._Query_todos(ctx, field) 348 if out.Values[i] == graphql.Null { 349 invalid = true 350 } 351 wg.Done() 352 }(i, field) 353 case "__type": 354 out.Values[i] = ec._Query___type(ctx, field) 355 case "__schema": 356 out.Values[i] = ec._Query___schema(ctx, field) 357 default: 358 panic("unknown field " + strconv.Quote(field.Name)) 359 } 360 } 361 wg.Wait() 362 if invalid { 363 return graphql.Null 364 } 365 return out 366 } 367 368 // nolint: vetshadow 369 func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { 370 rctx := &graphql.ResolverContext{ 371 Object: "Query", 372 Args: nil, 373 Field: field, 374 } 375 ctx = graphql.WithResolverContext(ctx, rctx) 376 resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { 377 ctx = rctx // use context from middleware stack in children 378 return ec.resolvers.Query().Todos(rctx) 379 }) 380 if resTmp == nil { 381 if !ec.HasError(rctx) { 382 ec.Errorf(ctx, "must not be null") 383 } 384 return graphql.Null 385 } 386 res := resTmp.([]Todo) 387 rctx.Result = res 388 389 arr1 := make(graphql.Array, len(res)) 390 var wg sync.WaitGroup 391 392 isLen1 := len(res) == 1 393 if !isLen1 { 394 wg.Add(len(res)) 395 } 396 397 for idx1 := range res { 398 idx1 := idx1 399 rctx := &graphql.ResolverContext{ 400 Index: &idx1, 401 Result: &res[idx1], 402 } 403 ctx := graphql.WithResolverContext(ctx, rctx) 404 f := func(idx1 int) { 405 if !isLen1 { 406 defer wg.Done() 407 } 408 arr1[idx1] = func() graphql.Marshaler { 409 410 return ec._Todo(ctx, field.Selections, &res[idx1]) 411 }() 412 } 413 if isLen1 { 414 f(idx1) 415 } else { 416 go f(idx1) 417 } 418 419 } 420 wg.Wait() 421 return arr1 422 } 423 424 // nolint: vetshadow 425 func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { 426 rawArgs := field.ArgumentMap(ec.Variables) 427 args, err := field_Query___type_args(rawArgs) 428 if err != nil { 429 ec.Error(ctx, err) 430 return graphql.Null 431 } 432 rctx := &graphql.ResolverContext{ 433 Object: "Query", 434 Args: args, 435 Field: field, 436 } 437 ctx = graphql.WithResolverContext(ctx, rctx) 438 resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { 439 ctx = rctx // use context from middleware stack in children 440 return ec.introspectType(args["name"].(string)), nil 441 }) 442 if resTmp == nil { 443 return graphql.Null 444 } 445 res := resTmp.(*introspection.Type) 446 rctx.Result = res 447 448 if res == nil { 449 return graphql.Null 450 } 451 452 return ec.___Type(ctx, field.Selections, res) 453 } 454 455 // nolint: vetshadow 456 func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { 457 rctx := &graphql.ResolverContext{ 458 Object: "Query", 459 Args: nil, 460 Field: field, 461 } 462 ctx = graphql.WithResolverContext(ctx, rctx) 463 resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { 464 ctx = rctx // use context from middleware stack in children 465 return ec.introspectSchema(), nil 466 }) 467 if resTmp == nil { 468 return graphql.Null 469 } 470 res := resTmp.(*introspection.Schema) 471 rctx.Result = res 472 473 if res == nil { 474 return graphql.Null 475 } 476 477 return ec.___Schema(ctx, field.Selections, res) 478 } 479 480 var todoImplementors = []string{"Todo"} 481 482 // nolint: gocyclo, errcheck, gas, goconst 483 func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { 484 fields := graphql.CollectFields(ctx, sel, todoImplementors) 485 486 var wg sync.WaitGroup 487 out := graphql.NewOrderedMap(len(fields)) 488 invalid := false 489 for i, field := range fields { 490 out.Keys[i] = field.Alias 491 492 switch field.Name { 493 case "__typename": 494 out.Values[i] = graphql.MarshalString("Todo") 495 case "id": 496 wg.Add(1) 497 go func(i int, field graphql.CollectedField) { 498 out.Values[i] = ec._Todo_id(ctx, field, obj) 499 if out.Values[i] == graphql.Null { 500 invalid = true 501 } 502 wg.Done() 503 }(i, field) 504 case "databaseId": 505 out.Values[i] = ec._Todo_databaseId(ctx, field, obj) 506 if out.Values[i] == graphql.Null { 507 invalid = true 508 } 509 case "text": 510 out.Values[i] = ec._Todo_text(ctx, field, obj) 511 if out.Values[i] == graphql.Null { 512 invalid = true 513 } 514 case "done": 515 out.Values[i] = ec._Todo_done(ctx, field, obj) 516 if out.Values[i] == graphql.Null { 517 invalid = true 518 } 519 case "user": 520 out.Values[i] = ec._Todo_user(ctx, field, obj) 521 if out.Values[i] == graphql.Null { 522 invalid = true 523 } 524 default: 525 panic("unknown field " + strconv.Quote(field.Name)) 526 } 527 } 528 wg.Wait() 529 if invalid { 530 return graphql.Null 531 } 532 return out 533 } 534 535 // nolint: vetshadow 536 func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { 537 rctx := &graphql.ResolverContext{ 538 Object: "Todo", 539 Args: nil, 540 Field: field, 541 } 542 ctx = graphql.WithResolverContext(ctx, rctx) 543 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 544 ctx = rctx // use context from middleware stack in children 545 return ec.resolvers.Todo().ID(rctx, obj) 546 }) 547 if resTmp == nil { 548 if !ec.HasError(rctx) { 549 ec.Errorf(ctx, "must not be null") 550 } 551 return graphql.Null 552 } 553 res := resTmp.(string) 554 rctx.Result = res 555 return graphql.MarshalID(res) 556 } 557 558 // nolint: vetshadow 559 func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { 560 rctx := &graphql.ResolverContext{ 561 Object: "Todo", 562 Args: nil, 563 Field: field, 564 } 565 ctx = graphql.WithResolverContext(ctx, rctx) 566 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 567 ctx = rctx // use context from middleware stack in children 568 return obj.DatabaseID, nil 569 }) 570 if resTmp == nil { 571 if !ec.HasError(rctx) { 572 ec.Errorf(ctx, "must not be null") 573 } 574 return graphql.Null 575 } 576 res := resTmp.(int) 577 rctx.Result = res 578 return graphql.MarshalInt(res) 579 } 580 581 // nolint: vetshadow 582 func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { 583 rctx := &graphql.ResolverContext{ 584 Object: "Todo", 585 Args: nil, 586 Field: field, 587 } 588 ctx = graphql.WithResolverContext(ctx, rctx) 589 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 590 ctx = rctx // use context from middleware stack in children 591 return obj.Description, nil 592 }) 593 if resTmp == nil { 594 if !ec.HasError(rctx) { 595 ec.Errorf(ctx, "must not be null") 596 } 597 return graphql.Null 598 } 599 res := resTmp.(string) 600 rctx.Result = res 601 return graphql.MarshalString(res) 602 } 603 604 // nolint: vetshadow 605 func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { 606 rctx := &graphql.ResolverContext{ 607 Object: "Todo", 608 Args: nil, 609 Field: field, 610 } 611 ctx = graphql.WithResolverContext(ctx, rctx) 612 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 613 ctx = rctx // use context from middleware stack in children 614 return obj.Done, nil 615 }) 616 if resTmp == nil { 617 if !ec.HasError(rctx) { 618 ec.Errorf(ctx, "must not be null") 619 } 620 return graphql.Null 621 } 622 res := resTmp.(bool) 623 rctx.Result = res 624 return graphql.MarshalBoolean(res) 625 } 626 627 // nolint: vetshadow 628 func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { 629 rctx := &graphql.ResolverContext{ 630 Object: "Todo", 631 Args: nil, 632 Field: field, 633 } 634 ctx = graphql.WithResolverContext(ctx, rctx) 635 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 636 ctx = rctx // use context from middleware stack in children 637 return obj.User, nil 638 }) 639 if resTmp == nil { 640 if !ec.HasError(rctx) { 641 ec.Errorf(ctx, "must not be null") 642 } 643 return graphql.Null 644 } 645 res := resTmp.(User) 646 rctx.Result = res 647 648 return ec._User(ctx, field.Selections, &res) 649 } 650 651 var userImplementors = []string{"User"} 652 653 // nolint: gocyclo, errcheck, gas, goconst 654 func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { 655 fields := graphql.CollectFields(ctx, sel, userImplementors) 656 657 out := graphql.NewOrderedMap(len(fields)) 658 invalid := false 659 for i, field := range fields { 660 out.Keys[i] = field.Alias 661 662 switch field.Name { 663 case "__typename": 664 out.Values[i] = graphql.MarshalString("User") 665 case "id": 666 out.Values[i] = ec._User_id(ctx, field, obj) 667 if out.Values[i] == graphql.Null { 668 invalid = true 669 } 670 case "name": 671 out.Values[i] = ec._User_name(ctx, field, obj) 672 if out.Values[i] == graphql.Null { 673 invalid = true 674 } 675 default: 676 panic("unknown field " + strconv.Quote(field.Name)) 677 } 678 } 679 680 if invalid { 681 return graphql.Null 682 } 683 return out 684 } 685 686 // nolint: vetshadow 687 func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { 688 rctx := &graphql.ResolverContext{ 689 Object: "User", 690 Args: nil, 691 Field: field, 692 } 693 ctx = graphql.WithResolverContext(ctx, rctx) 694 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 695 ctx = rctx // use context from middleware stack in children 696 return obj.ID, nil 697 }) 698 if resTmp == nil { 699 if !ec.HasError(rctx) { 700 ec.Errorf(ctx, "must not be null") 701 } 702 return graphql.Null 703 } 704 res := resTmp.(string) 705 rctx.Result = res 706 return graphql.MarshalID(res) 707 } 708 709 // nolint: vetshadow 710 func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { 711 rctx := &graphql.ResolverContext{ 712 Object: "User", 713 Args: nil, 714 Field: field, 715 } 716 ctx = graphql.WithResolverContext(ctx, rctx) 717 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 718 ctx = rctx // use context from middleware stack in children 719 return obj.FullName(), nil 720 }) 721 if resTmp == nil { 722 if !ec.HasError(rctx) { 723 ec.Errorf(ctx, "must not be null") 724 } 725 return graphql.Null 726 } 727 res := resTmp.(string) 728 rctx.Result = res 729 return graphql.MarshalString(res) 730 } 731 732 var __DirectiveImplementors = []string{"__Directive"} 733 734 // nolint: gocyclo, errcheck, gas, goconst 735 func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { 736 fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) 737 738 out := graphql.NewOrderedMap(len(fields)) 739 invalid := false 740 for i, field := range fields { 741 out.Keys[i] = field.Alias 742 743 switch field.Name { 744 case "__typename": 745 out.Values[i] = graphql.MarshalString("__Directive") 746 case "name": 747 out.Values[i] = ec.___Directive_name(ctx, field, obj) 748 if out.Values[i] == graphql.Null { 749 invalid = true 750 } 751 case "description": 752 out.Values[i] = ec.___Directive_description(ctx, field, obj) 753 case "locations": 754 out.Values[i] = ec.___Directive_locations(ctx, field, obj) 755 if out.Values[i] == graphql.Null { 756 invalid = true 757 } 758 case "args": 759 out.Values[i] = ec.___Directive_args(ctx, field, obj) 760 if out.Values[i] == graphql.Null { 761 invalid = true 762 } 763 default: 764 panic("unknown field " + strconv.Quote(field.Name)) 765 } 766 } 767 768 if invalid { 769 return graphql.Null 770 } 771 return out 772 } 773 774 // nolint: vetshadow 775 func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { 776 rctx := &graphql.ResolverContext{ 777 Object: "__Directive", 778 Args: nil, 779 Field: field, 780 } 781 ctx = graphql.WithResolverContext(ctx, rctx) 782 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 783 ctx = rctx // use context from middleware stack in children 784 return obj.Name, nil 785 }) 786 if resTmp == nil { 787 if !ec.HasError(rctx) { 788 ec.Errorf(ctx, "must not be null") 789 } 790 return graphql.Null 791 } 792 res := resTmp.(string) 793 rctx.Result = res 794 return graphql.MarshalString(res) 795 } 796 797 // nolint: vetshadow 798 func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { 799 rctx := &graphql.ResolverContext{ 800 Object: "__Directive", 801 Args: nil, 802 Field: field, 803 } 804 ctx = graphql.WithResolverContext(ctx, rctx) 805 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 806 ctx = rctx // use context from middleware stack in children 807 return obj.Description, nil 808 }) 809 if resTmp == nil { 810 return graphql.Null 811 } 812 res := resTmp.(string) 813 rctx.Result = res 814 return graphql.MarshalString(res) 815 } 816 817 // nolint: vetshadow 818 func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { 819 rctx := &graphql.ResolverContext{ 820 Object: "__Directive", 821 Args: nil, 822 Field: field, 823 } 824 ctx = graphql.WithResolverContext(ctx, rctx) 825 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 826 ctx = rctx // use context from middleware stack in children 827 return obj.Locations, nil 828 }) 829 if resTmp == nil { 830 if !ec.HasError(rctx) { 831 ec.Errorf(ctx, "must not be null") 832 } 833 return graphql.Null 834 } 835 res := resTmp.([]string) 836 rctx.Result = res 837 838 arr1 := make(graphql.Array, len(res)) 839 840 for idx1 := range res { 841 arr1[idx1] = func() graphql.Marshaler { 842 return graphql.MarshalString(res[idx1]) 843 }() 844 } 845 846 return arr1 847 } 848 849 // nolint: vetshadow 850 func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { 851 rctx := &graphql.ResolverContext{ 852 Object: "__Directive", 853 Args: nil, 854 Field: field, 855 } 856 ctx = graphql.WithResolverContext(ctx, rctx) 857 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 858 ctx = rctx // use context from middleware stack in children 859 return obj.Args, nil 860 }) 861 if resTmp == nil { 862 if !ec.HasError(rctx) { 863 ec.Errorf(ctx, "must not be null") 864 } 865 return graphql.Null 866 } 867 res := resTmp.([]introspection.InputValue) 868 rctx.Result = res 869 870 arr1 := make(graphql.Array, len(res)) 871 var wg sync.WaitGroup 872 873 isLen1 := len(res) == 1 874 if !isLen1 { 875 wg.Add(len(res)) 876 } 877 878 for idx1 := range res { 879 idx1 := idx1 880 rctx := &graphql.ResolverContext{ 881 Index: &idx1, 882 Result: &res[idx1], 883 } 884 ctx := graphql.WithResolverContext(ctx, rctx) 885 f := func(idx1 int) { 886 if !isLen1 { 887 defer wg.Done() 888 } 889 arr1[idx1] = func() graphql.Marshaler { 890 891 return ec.___InputValue(ctx, field.Selections, &res[idx1]) 892 }() 893 } 894 if isLen1 { 895 f(idx1) 896 } else { 897 go f(idx1) 898 } 899 900 } 901 wg.Wait() 902 return arr1 903 } 904 905 var __EnumValueImplementors = []string{"__EnumValue"} 906 907 // nolint: gocyclo, errcheck, gas, goconst 908 func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { 909 fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) 910 911 out := graphql.NewOrderedMap(len(fields)) 912 invalid := false 913 for i, field := range fields { 914 out.Keys[i] = field.Alias 915 916 switch field.Name { 917 case "__typename": 918 out.Values[i] = graphql.MarshalString("__EnumValue") 919 case "name": 920 out.Values[i] = ec.___EnumValue_name(ctx, field, obj) 921 if out.Values[i] == graphql.Null { 922 invalid = true 923 } 924 case "description": 925 out.Values[i] = ec.___EnumValue_description(ctx, field, obj) 926 case "isDeprecated": 927 out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) 928 if out.Values[i] == graphql.Null { 929 invalid = true 930 } 931 case "deprecationReason": 932 out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) 933 default: 934 panic("unknown field " + strconv.Quote(field.Name)) 935 } 936 } 937 938 if invalid { 939 return graphql.Null 940 } 941 return out 942 } 943 944 // nolint: vetshadow 945 func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { 946 rctx := &graphql.ResolverContext{ 947 Object: "__EnumValue", 948 Args: nil, 949 Field: field, 950 } 951 ctx = graphql.WithResolverContext(ctx, rctx) 952 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 953 ctx = rctx // use context from middleware stack in children 954 return obj.Name, nil 955 }) 956 if resTmp == nil { 957 if !ec.HasError(rctx) { 958 ec.Errorf(ctx, "must not be null") 959 } 960 return graphql.Null 961 } 962 res := resTmp.(string) 963 rctx.Result = res 964 return graphql.MarshalString(res) 965 } 966 967 // nolint: vetshadow 968 func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { 969 rctx := &graphql.ResolverContext{ 970 Object: "__EnumValue", 971 Args: nil, 972 Field: field, 973 } 974 ctx = graphql.WithResolverContext(ctx, rctx) 975 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 976 ctx = rctx // use context from middleware stack in children 977 return obj.Description, nil 978 }) 979 if resTmp == nil { 980 return graphql.Null 981 } 982 res := resTmp.(string) 983 rctx.Result = res 984 return graphql.MarshalString(res) 985 } 986 987 // nolint: vetshadow 988 func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { 989 rctx := &graphql.ResolverContext{ 990 Object: "__EnumValue", 991 Args: nil, 992 Field: field, 993 } 994 ctx = graphql.WithResolverContext(ctx, rctx) 995 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 996 ctx = rctx // use context from middleware stack in children 997 return obj.IsDeprecated, nil 998 }) 999 if resTmp == nil { 1000 if !ec.HasError(rctx) { 1001 ec.Errorf(ctx, "must not be null") 1002 } 1003 return graphql.Null 1004 } 1005 res := resTmp.(bool) 1006 rctx.Result = res 1007 return graphql.MarshalBoolean(res) 1008 } 1009 1010 // nolint: vetshadow 1011 func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { 1012 rctx := &graphql.ResolverContext{ 1013 Object: "__EnumValue", 1014 Args: nil, 1015 Field: field, 1016 } 1017 ctx = graphql.WithResolverContext(ctx, rctx) 1018 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1019 ctx = rctx // use context from middleware stack in children 1020 return obj.DeprecationReason, nil 1021 }) 1022 if resTmp == nil { 1023 return graphql.Null 1024 } 1025 res := resTmp.(string) 1026 rctx.Result = res 1027 return graphql.MarshalString(res) 1028 } 1029 1030 var __FieldImplementors = []string{"__Field"} 1031 1032 // nolint: gocyclo, errcheck, gas, goconst 1033 func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { 1034 fields := graphql.CollectFields(ctx, sel, __FieldImplementors) 1035 1036 out := graphql.NewOrderedMap(len(fields)) 1037 invalid := false 1038 for i, field := range fields { 1039 out.Keys[i] = field.Alias 1040 1041 switch field.Name { 1042 case "__typename": 1043 out.Values[i] = graphql.MarshalString("__Field") 1044 case "name": 1045 out.Values[i] = ec.___Field_name(ctx, field, obj) 1046 if out.Values[i] == graphql.Null { 1047 invalid = true 1048 } 1049 case "description": 1050 out.Values[i] = ec.___Field_description(ctx, field, obj) 1051 case "args": 1052 out.Values[i] = ec.___Field_args(ctx, field, obj) 1053 if out.Values[i] == graphql.Null { 1054 invalid = true 1055 } 1056 case "type": 1057 out.Values[i] = ec.___Field_type(ctx, field, obj) 1058 if out.Values[i] == graphql.Null { 1059 invalid = true 1060 } 1061 case "isDeprecated": 1062 out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) 1063 if out.Values[i] == graphql.Null { 1064 invalid = true 1065 } 1066 case "deprecationReason": 1067 out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) 1068 default: 1069 panic("unknown field " + strconv.Quote(field.Name)) 1070 } 1071 } 1072 1073 if invalid { 1074 return graphql.Null 1075 } 1076 return out 1077 } 1078 1079 // nolint: vetshadow 1080 func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { 1081 rctx := &graphql.ResolverContext{ 1082 Object: "__Field", 1083 Args: nil, 1084 Field: field, 1085 } 1086 ctx = graphql.WithResolverContext(ctx, rctx) 1087 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1088 ctx = rctx // use context from middleware stack in children 1089 return obj.Name, nil 1090 }) 1091 if resTmp == nil { 1092 if !ec.HasError(rctx) { 1093 ec.Errorf(ctx, "must not be null") 1094 } 1095 return graphql.Null 1096 } 1097 res := resTmp.(string) 1098 rctx.Result = res 1099 return graphql.MarshalString(res) 1100 } 1101 1102 // nolint: vetshadow 1103 func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { 1104 rctx := &graphql.ResolverContext{ 1105 Object: "__Field", 1106 Args: nil, 1107 Field: field, 1108 } 1109 ctx = graphql.WithResolverContext(ctx, rctx) 1110 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1111 ctx = rctx // use context from middleware stack in children 1112 return obj.Description, nil 1113 }) 1114 if resTmp == nil { 1115 return graphql.Null 1116 } 1117 res := resTmp.(string) 1118 rctx.Result = res 1119 return graphql.MarshalString(res) 1120 } 1121 1122 // nolint: vetshadow 1123 func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { 1124 rctx := &graphql.ResolverContext{ 1125 Object: "__Field", 1126 Args: nil, 1127 Field: field, 1128 } 1129 ctx = graphql.WithResolverContext(ctx, rctx) 1130 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1131 ctx = rctx // use context from middleware stack in children 1132 return obj.Args, nil 1133 }) 1134 if resTmp == nil { 1135 if !ec.HasError(rctx) { 1136 ec.Errorf(ctx, "must not be null") 1137 } 1138 return graphql.Null 1139 } 1140 res := resTmp.([]introspection.InputValue) 1141 rctx.Result = res 1142 1143 arr1 := make(graphql.Array, len(res)) 1144 var wg sync.WaitGroup 1145 1146 isLen1 := len(res) == 1 1147 if !isLen1 { 1148 wg.Add(len(res)) 1149 } 1150 1151 for idx1 := range res { 1152 idx1 := idx1 1153 rctx := &graphql.ResolverContext{ 1154 Index: &idx1, 1155 Result: &res[idx1], 1156 } 1157 ctx := graphql.WithResolverContext(ctx, rctx) 1158 f := func(idx1 int) { 1159 if !isLen1 { 1160 defer wg.Done() 1161 } 1162 arr1[idx1] = func() graphql.Marshaler { 1163 1164 return ec.___InputValue(ctx, field.Selections, &res[idx1]) 1165 }() 1166 } 1167 if isLen1 { 1168 f(idx1) 1169 } else { 1170 go f(idx1) 1171 } 1172 1173 } 1174 wg.Wait() 1175 return arr1 1176 } 1177 1178 // nolint: vetshadow 1179 func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { 1180 rctx := &graphql.ResolverContext{ 1181 Object: "__Field", 1182 Args: nil, 1183 Field: field, 1184 } 1185 ctx = graphql.WithResolverContext(ctx, rctx) 1186 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1187 ctx = rctx // use context from middleware stack in children 1188 return obj.Type, nil 1189 }) 1190 if resTmp == nil { 1191 if !ec.HasError(rctx) { 1192 ec.Errorf(ctx, "must not be null") 1193 } 1194 return graphql.Null 1195 } 1196 res := resTmp.(*introspection.Type) 1197 rctx.Result = res 1198 1199 if res == nil { 1200 if !ec.HasError(rctx) { 1201 ec.Errorf(ctx, "must not be null") 1202 } 1203 return graphql.Null 1204 } 1205 1206 return ec.___Type(ctx, field.Selections, res) 1207 } 1208 1209 // nolint: vetshadow 1210 func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { 1211 rctx := &graphql.ResolverContext{ 1212 Object: "__Field", 1213 Args: nil, 1214 Field: field, 1215 } 1216 ctx = graphql.WithResolverContext(ctx, rctx) 1217 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1218 ctx = rctx // use context from middleware stack in children 1219 return obj.IsDeprecated, nil 1220 }) 1221 if resTmp == nil { 1222 if !ec.HasError(rctx) { 1223 ec.Errorf(ctx, "must not be null") 1224 } 1225 return graphql.Null 1226 } 1227 res := resTmp.(bool) 1228 rctx.Result = res 1229 return graphql.MarshalBoolean(res) 1230 } 1231 1232 // nolint: vetshadow 1233 func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { 1234 rctx := &graphql.ResolverContext{ 1235 Object: "__Field", 1236 Args: nil, 1237 Field: field, 1238 } 1239 ctx = graphql.WithResolverContext(ctx, rctx) 1240 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1241 ctx = rctx // use context from middleware stack in children 1242 return obj.DeprecationReason, nil 1243 }) 1244 if resTmp == nil { 1245 return graphql.Null 1246 } 1247 res := resTmp.(string) 1248 rctx.Result = res 1249 return graphql.MarshalString(res) 1250 } 1251 1252 var __InputValueImplementors = []string{"__InputValue"} 1253 1254 // nolint: gocyclo, errcheck, gas, goconst 1255 func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { 1256 fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) 1257 1258 out := graphql.NewOrderedMap(len(fields)) 1259 invalid := false 1260 for i, field := range fields { 1261 out.Keys[i] = field.Alias 1262 1263 switch field.Name { 1264 case "__typename": 1265 out.Values[i] = graphql.MarshalString("__InputValue") 1266 case "name": 1267 out.Values[i] = ec.___InputValue_name(ctx, field, obj) 1268 if out.Values[i] == graphql.Null { 1269 invalid = true 1270 } 1271 case "description": 1272 out.Values[i] = ec.___InputValue_description(ctx, field, obj) 1273 case "type": 1274 out.Values[i] = ec.___InputValue_type(ctx, field, obj) 1275 if out.Values[i] == graphql.Null { 1276 invalid = true 1277 } 1278 case "defaultValue": 1279 out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) 1280 default: 1281 panic("unknown field " + strconv.Quote(field.Name)) 1282 } 1283 } 1284 1285 if invalid { 1286 return graphql.Null 1287 } 1288 return out 1289 } 1290 1291 // nolint: vetshadow 1292 func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { 1293 rctx := &graphql.ResolverContext{ 1294 Object: "__InputValue", 1295 Args: nil, 1296 Field: field, 1297 } 1298 ctx = graphql.WithResolverContext(ctx, rctx) 1299 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1300 ctx = rctx // use context from middleware stack in children 1301 return obj.Name, nil 1302 }) 1303 if resTmp == nil { 1304 if !ec.HasError(rctx) { 1305 ec.Errorf(ctx, "must not be null") 1306 } 1307 return graphql.Null 1308 } 1309 res := resTmp.(string) 1310 rctx.Result = res 1311 return graphql.MarshalString(res) 1312 } 1313 1314 // nolint: vetshadow 1315 func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { 1316 rctx := &graphql.ResolverContext{ 1317 Object: "__InputValue", 1318 Args: nil, 1319 Field: field, 1320 } 1321 ctx = graphql.WithResolverContext(ctx, rctx) 1322 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1323 ctx = rctx // use context from middleware stack in children 1324 return obj.Description, nil 1325 }) 1326 if resTmp == nil { 1327 return graphql.Null 1328 } 1329 res := resTmp.(string) 1330 rctx.Result = res 1331 return graphql.MarshalString(res) 1332 } 1333 1334 // nolint: vetshadow 1335 func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { 1336 rctx := &graphql.ResolverContext{ 1337 Object: "__InputValue", 1338 Args: nil, 1339 Field: field, 1340 } 1341 ctx = graphql.WithResolverContext(ctx, rctx) 1342 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1343 ctx = rctx // use context from middleware stack in children 1344 return obj.Type, nil 1345 }) 1346 if resTmp == nil { 1347 if !ec.HasError(rctx) { 1348 ec.Errorf(ctx, "must not be null") 1349 } 1350 return graphql.Null 1351 } 1352 res := resTmp.(*introspection.Type) 1353 rctx.Result = res 1354 1355 if res == nil { 1356 if !ec.HasError(rctx) { 1357 ec.Errorf(ctx, "must not be null") 1358 } 1359 return graphql.Null 1360 } 1361 1362 return ec.___Type(ctx, field.Selections, res) 1363 } 1364 1365 // nolint: vetshadow 1366 func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { 1367 rctx := &graphql.ResolverContext{ 1368 Object: "__InputValue", 1369 Args: nil, 1370 Field: field, 1371 } 1372 ctx = graphql.WithResolverContext(ctx, rctx) 1373 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1374 ctx = rctx // use context from middleware stack in children 1375 return obj.DefaultValue, nil 1376 }) 1377 if resTmp == nil { 1378 return graphql.Null 1379 } 1380 res := resTmp.(*string) 1381 rctx.Result = res 1382 1383 if res == nil { 1384 return graphql.Null 1385 } 1386 return graphql.MarshalString(*res) 1387 } 1388 1389 var __SchemaImplementors = []string{"__Schema"} 1390 1391 // nolint: gocyclo, errcheck, gas, goconst 1392 func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { 1393 fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) 1394 1395 out := graphql.NewOrderedMap(len(fields)) 1396 invalid := false 1397 for i, field := range fields { 1398 out.Keys[i] = field.Alias 1399 1400 switch field.Name { 1401 case "__typename": 1402 out.Values[i] = graphql.MarshalString("__Schema") 1403 case "types": 1404 out.Values[i] = ec.___Schema_types(ctx, field, obj) 1405 if out.Values[i] == graphql.Null { 1406 invalid = true 1407 } 1408 case "queryType": 1409 out.Values[i] = ec.___Schema_queryType(ctx, field, obj) 1410 if out.Values[i] == graphql.Null { 1411 invalid = true 1412 } 1413 case "mutationType": 1414 out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) 1415 case "subscriptionType": 1416 out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) 1417 case "directives": 1418 out.Values[i] = ec.___Schema_directives(ctx, field, obj) 1419 if out.Values[i] == graphql.Null { 1420 invalid = true 1421 } 1422 default: 1423 panic("unknown field " + strconv.Quote(field.Name)) 1424 } 1425 } 1426 1427 if invalid { 1428 return graphql.Null 1429 } 1430 return out 1431 } 1432 1433 // nolint: vetshadow 1434 func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { 1435 rctx := &graphql.ResolverContext{ 1436 Object: "__Schema", 1437 Args: nil, 1438 Field: field, 1439 } 1440 ctx = graphql.WithResolverContext(ctx, rctx) 1441 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1442 ctx = rctx // use context from middleware stack in children 1443 return obj.Types(), nil 1444 }) 1445 if resTmp == nil { 1446 if !ec.HasError(rctx) { 1447 ec.Errorf(ctx, "must not be null") 1448 } 1449 return graphql.Null 1450 } 1451 res := resTmp.([]introspection.Type) 1452 rctx.Result = res 1453 1454 arr1 := make(graphql.Array, len(res)) 1455 var wg sync.WaitGroup 1456 1457 isLen1 := len(res) == 1 1458 if !isLen1 { 1459 wg.Add(len(res)) 1460 } 1461 1462 for idx1 := range res { 1463 idx1 := idx1 1464 rctx := &graphql.ResolverContext{ 1465 Index: &idx1, 1466 Result: &res[idx1], 1467 } 1468 ctx := graphql.WithResolverContext(ctx, rctx) 1469 f := func(idx1 int) { 1470 if !isLen1 { 1471 defer wg.Done() 1472 } 1473 arr1[idx1] = func() graphql.Marshaler { 1474 1475 return ec.___Type(ctx, field.Selections, &res[idx1]) 1476 }() 1477 } 1478 if isLen1 { 1479 f(idx1) 1480 } else { 1481 go f(idx1) 1482 } 1483 1484 } 1485 wg.Wait() 1486 return arr1 1487 } 1488 1489 // nolint: vetshadow 1490 func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { 1491 rctx := &graphql.ResolverContext{ 1492 Object: "__Schema", 1493 Args: nil, 1494 Field: field, 1495 } 1496 ctx = graphql.WithResolverContext(ctx, rctx) 1497 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1498 ctx = rctx // use context from middleware stack in children 1499 return obj.QueryType(), nil 1500 }) 1501 if resTmp == nil { 1502 if !ec.HasError(rctx) { 1503 ec.Errorf(ctx, "must not be null") 1504 } 1505 return graphql.Null 1506 } 1507 res := resTmp.(*introspection.Type) 1508 rctx.Result = res 1509 1510 if res == nil { 1511 if !ec.HasError(rctx) { 1512 ec.Errorf(ctx, "must not be null") 1513 } 1514 return graphql.Null 1515 } 1516 1517 return ec.___Type(ctx, field.Selections, res) 1518 } 1519 1520 // nolint: vetshadow 1521 func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { 1522 rctx := &graphql.ResolverContext{ 1523 Object: "__Schema", 1524 Args: nil, 1525 Field: field, 1526 } 1527 ctx = graphql.WithResolverContext(ctx, rctx) 1528 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1529 ctx = rctx // use context from middleware stack in children 1530 return obj.MutationType(), nil 1531 }) 1532 if resTmp == nil { 1533 return graphql.Null 1534 } 1535 res := resTmp.(*introspection.Type) 1536 rctx.Result = res 1537 1538 if res == nil { 1539 return graphql.Null 1540 } 1541 1542 return ec.___Type(ctx, field.Selections, res) 1543 } 1544 1545 // nolint: vetshadow 1546 func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { 1547 rctx := &graphql.ResolverContext{ 1548 Object: "__Schema", 1549 Args: nil, 1550 Field: field, 1551 } 1552 ctx = graphql.WithResolverContext(ctx, rctx) 1553 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1554 ctx = rctx // use context from middleware stack in children 1555 return obj.SubscriptionType(), nil 1556 }) 1557 if resTmp == nil { 1558 return graphql.Null 1559 } 1560 res := resTmp.(*introspection.Type) 1561 rctx.Result = res 1562 1563 if res == nil { 1564 return graphql.Null 1565 } 1566 1567 return ec.___Type(ctx, field.Selections, res) 1568 } 1569 1570 // nolint: vetshadow 1571 func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { 1572 rctx := &graphql.ResolverContext{ 1573 Object: "__Schema", 1574 Args: nil, 1575 Field: field, 1576 } 1577 ctx = graphql.WithResolverContext(ctx, rctx) 1578 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1579 ctx = rctx // use context from middleware stack in children 1580 return obj.Directives(), nil 1581 }) 1582 if resTmp == nil { 1583 if !ec.HasError(rctx) { 1584 ec.Errorf(ctx, "must not be null") 1585 } 1586 return graphql.Null 1587 } 1588 res := resTmp.([]introspection.Directive) 1589 rctx.Result = res 1590 1591 arr1 := make(graphql.Array, len(res)) 1592 var wg sync.WaitGroup 1593 1594 isLen1 := len(res) == 1 1595 if !isLen1 { 1596 wg.Add(len(res)) 1597 } 1598 1599 for idx1 := range res { 1600 idx1 := idx1 1601 rctx := &graphql.ResolverContext{ 1602 Index: &idx1, 1603 Result: &res[idx1], 1604 } 1605 ctx := graphql.WithResolverContext(ctx, rctx) 1606 f := func(idx1 int) { 1607 if !isLen1 { 1608 defer wg.Done() 1609 } 1610 arr1[idx1] = func() graphql.Marshaler { 1611 1612 return ec.___Directive(ctx, field.Selections, &res[idx1]) 1613 }() 1614 } 1615 if isLen1 { 1616 f(idx1) 1617 } else { 1618 go f(idx1) 1619 } 1620 1621 } 1622 wg.Wait() 1623 return arr1 1624 } 1625 1626 var __TypeImplementors = []string{"__Type"} 1627 1628 // nolint: gocyclo, errcheck, gas, goconst 1629 func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { 1630 fields := graphql.CollectFields(ctx, sel, __TypeImplementors) 1631 1632 out := graphql.NewOrderedMap(len(fields)) 1633 invalid := false 1634 for i, field := range fields { 1635 out.Keys[i] = field.Alias 1636 1637 switch field.Name { 1638 case "__typename": 1639 out.Values[i] = graphql.MarshalString("__Type") 1640 case "kind": 1641 out.Values[i] = ec.___Type_kind(ctx, field, obj) 1642 if out.Values[i] == graphql.Null { 1643 invalid = true 1644 } 1645 case "name": 1646 out.Values[i] = ec.___Type_name(ctx, field, obj) 1647 case "description": 1648 out.Values[i] = ec.___Type_description(ctx, field, obj) 1649 case "fields": 1650 out.Values[i] = ec.___Type_fields(ctx, field, obj) 1651 case "interfaces": 1652 out.Values[i] = ec.___Type_interfaces(ctx, field, obj) 1653 case "possibleTypes": 1654 out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) 1655 case "enumValues": 1656 out.Values[i] = ec.___Type_enumValues(ctx, field, obj) 1657 case "inputFields": 1658 out.Values[i] = ec.___Type_inputFields(ctx, field, obj) 1659 case "ofType": 1660 out.Values[i] = ec.___Type_ofType(ctx, field, obj) 1661 default: 1662 panic("unknown field " + strconv.Quote(field.Name)) 1663 } 1664 } 1665 1666 if invalid { 1667 return graphql.Null 1668 } 1669 return out 1670 } 1671 1672 // nolint: vetshadow 1673 func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 1674 rctx := &graphql.ResolverContext{ 1675 Object: "__Type", 1676 Args: nil, 1677 Field: field, 1678 } 1679 ctx = graphql.WithResolverContext(ctx, rctx) 1680 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1681 ctx = rctx // use context from middleware stack in children 1682 return obj.Kind(), nil 1683 }) 1684 if resTmp == nil { 1685 if !ec.HasError(rctx) { 1686 ec.Errorf(ctx, "must not be null") 1687 } 1688 return graphql.Null 1689 } 1690 res := resTmp.(string) 1691 rctx.Result = res 1692 return graphql.MarshalString(res) 1693 } 1694 1695 // nolint: vetshadow 1696 func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 1697 rctx := &graphql.ResolverContext{ 1698 Object: "__Type", 1699 Args: nil, 1700 Field: field, 1701 } 1702 ctx = graphql.WithResolverContext(ctx, rctx) 1703 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1704 ctx = rctx // use context from middleware stack in children 1705 return obj.Name(), nil 1706 }) 1707 if resTmp == nil { 1708 return graphql.Null 1709 } 1710 res := resTmp.(*string) 1711 rctx.Result = res 1712 1713 if res == nil { 1714 return graphql.Null 1715 } 1716 return graphql.MarshalString(*res) 1717 } 1718 1719 // nolint: vetshadow 1720 func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 1721 rctx := &graphql.ResolverContext{ 1722 Object: "__Type", 1723 Args: nil, 1724 Field: field, 1725 } 1726 ctx = graphql.WithResolverContext(ctx, rctx) 1727 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1728 ctx = rctx // use context from middleware stack in children 1729 return obj.Description(), nil 1730 }) 1731 if resTmp == nil { 1732 return graphql.Null 1733 } 1734 res := resTmp.(string) 1735 rctx.Result = res 1736 return graphql.MarshalString(res) 1737 } 1738 1739 // nolint: vetshadow 1740 func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 1741 rawArgs := field.ArgumentMap(ec.Variables) 1742 args, err := field___Type_fields_args(rawArgs) 1743 if err != nil { 1744 ec.Error(ctx, err) 1745 return graphql.Null 1746 } 1747 rctx := &graphql.ResolverContext{ 1748 Object: "__Type", 1749 Args: args, 1750 Field: field, 1751 } 1752 ctx = graphql.WithResolverContext(ctx, rctx) 1753 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1754 ctx = rctx // use context from middleware stack in children 1755 return obj.Fields(args["includeDeprecated"].(bool)), nil 1756 }) 1757 if resTmp == nil { 1758 return graphql.Null 1759 } 1760 res := resTmp.([]introspection.Field) 1761 rctx.Result = res 1762 1763 arr1 := make(graphql.Array, len(res)) 1764 var wg sync.WaitGroup 1765 1766 isLen1 := len(res) == 1 1767 if !isLen1 { 1768 wg.Add(len(res)) 1769 } 1770 1771 for idx1 := range res { 1772 idx1 := idx1 1773 rctx := &graphql.ResolverContext{ 1774 Index: &idx1, 1775 Result: &res[idx1], 1776 } 1777 ctx := graphql.WithResolverContext(ctx, rctx) 1778 f := func(idx1 int) { 1779 if !isLen1 { 1780 defer wg.Done() 1781 } 1782 arr1[idx1] = func() graphql.Marshaler { 1783 1784 return ec.___Field(ctx, field.Selections, &res[idx1]) 1785 }() 1786 } 1787 if isLen1 { 1788 f(idx1) 1789 } else { 1790 go f(idx1) 1791 } 1792 1793 } 1794 wg.Wait() 1795 return arr1 1796 } 1797 1798 // nolint: vetshadow 1799 func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 1800 rctx := &graphql.ResolverContext{ 1801 Object: "__Type", 1802 Args: nil, 1803 Field: field, 1804 } 1805 ctx = graphql.WithResolverContext(ctx, rctx) 1806 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1807 ctx = rctx // use context from middleware stack in children 1808 return obj.Interfaces(), nil 1809 }) 1810 if resTmp == nil { 1811 return graphql.Null 1812 } 1813 res := resTmp.([]introspection.Type) 1814 rctx.Result = res 1815 1816 arr1 := make(graphql.Array, len(res)) 1817 var wg sync.WaitGroup 1818 1819 isLen1 := len(res) == 1 1820 if !isLen1 { 1821 wg.Add(len(res)) 1822 } 1823 1824 for idx1 := range res { 1825 idx1 := idx1 1826 rctx := &graphql.ResolverContext{ 1827 Index: &idx1, 1828 Result: &res[idx1], 1829 } 1830 ctx := graphql.WithResolverContext(ctx, rctx) 1831 f := func(idx1 int) { 1832 if !isLen1 { 1833 defer wg.Done() 1834 } 1835 arr1[idx1] = func() graphql.Marshaler { 1836 1837 return ec.___Type(ctx, field.Selections, &res[idx1]) 1838 }() 1839 } 1840 if isLen1 { 1841 f(idx1) 1842 } else { 1843 go f(idx1) 1844 } 1845 1846 } 1847 wg.Wait() 1848 return arr1 1849 } 1850 1851 // nolint: vetshadow 1852 func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 1853 rctx := &graphql.ResolverContext{ 1854 Object: "__Type", 1855 Args: nil, 1856 Field: field, 1857 } 1858 ctx = graphql.WithResolverContext(ctx, rctx) 1859 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1860 ctx = rctx // use context from middleware stack in children 1861 return obj.PossibleTypes(), nil 1862 }) 1863 if resTmp == nil { 1864 return graphql.Null 1865 } 1866 res := resTmp.([]introspection.Type) 1867 rctx.Result = res 1868 1869 arr1 := make(graphql.Array, len(res)) 1870 var wg sync.WaitGroup 1871 1872 isLen1 := len(res) == 1 1873 if !isLen1 { 1874 wg.Add(len(res)) 1875 } 1876 1877 for idx1 := range res { 1878 idx1 := idx1 1879 rctx := &graphql.ResolverContext{ 1880 Index: &idx1, 1881 Result: &res[idx1], 1882 } 1883 ctx := graphql.WithResolverContext(ctx, rctx) 1884 f := func(idx1 int) { 1885 if !isLen1 { 1886 defer wg.Done() 1887 } 1888 arr1[idx1] = func() graphql.Marshaler { 1889 1890 return ec.___Type(ctx, field.Selections, &res[idx1]) 1891 }() 1892 } 1893 if isLen1 { 1894 f(idx1) 1895 } else { 1896 go f(idx1) 1897 } 1898 1899 } 1900 wg.Wait() 1901 return arr1 1902 } 1903 1904 // nolint: vetshadow 1905 func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 1906 rawArgs := field.ArgumentMap(ec.Variables) 1907 args, err := field___Type_enumValues_args(rawArgs) 1908 if err != nil { 1909 ec.Error(ctx, err) 1910 return graphql.Null 1911 } 1912 rctx := &graphql.ResolverContext{ 1913 Object: "__Type", 1914 Args: args, 1915 Field: field, 1916 } 1917 ctx = graphql.WithResolverContext(ctx, rctx) 1918 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1919 ctx = rctx // use context from middleware stack in children 1920 return obj.EnumValues(args["includeDeprecated"].(bool)), nil 1921 }) 1922 if resTmp == nil { 1923 return graphql.Null 1924 } 1925 res := resTmp.([]introspection.EnumValue) 1926 rctx.Result = res 1927 1928 arr1 := make(graphql.Array, len(res)) 1929 var wg sync.WaitGroup 1930 1931 isLen1 := len(res) == 1 1932 if !isLen1 { 1933 wg.Add(len(res)) 1934 } 1935 1936 for idx1 := range res { 1937 idx1 := idx1 1938 rctx := &graphql.ResolverContext{ 1939 Index: &idx1, 1940 Result: &res[idx1], 1941 } 1942 ctx := graphql.WithResolverContext(ctx, rctx) 1943 f := func(idx1 int) { 1944 if !isLen1 { 1945 defer wg.Done() 1946 } 1947 arr1[idx1] = func() graphql.Marshaler { 1948 1949 return ec.___EnumValue(ctx, field.Selections, &res[idx1]) 1950 }() 1951 } 1952 if isLen1 { 1953 f(idx1) 1954 } else { 1955 go f(idx1) 1956 } 1957 1958 } 1959 wg.Wait() 1960 return arr1 1961 } 1962 1963 // nolint: vetshadow 1964 func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 1965 rctx := &graphql.ResolverContext{ 1966 Object: "__Type", 1967 Args: nil, 1968 Field: field, 1969 } 1970 ctx = graphql.WithResolverContext(ctx, rctx) 1971 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1972 ctx = rctx // use context from middleware stack in children 1973 return obj.InputFields(), nil 1974 }) 1975 if resTmp == nil { 1976 return graphql.Null 1977 } 1978 res := resTmp.([]introspection.InputValue) 1979 rctx.Result = res 1980 1981 arr1 := make(graphql.Array, len(res)) 1982 var wg sync.WaitGroup 1983 1984 isLen1 := len(res) == 1 1985 if !isLen1 { 1986 wg.Add(len(res)) 1987 } 1988 1989 for idx1 := range res { 1990 idx1 := idx1 1991 rctx := &graphql.ResolverContext{ 1992 Index: &idx1, 1993 Result: &res[idx1], 1994 } 1995 ctx := graphql.WithResolverContext(ctx, rctx) 1996 f := func(idx1 int) { 1997 if !isLen1 { 1998 defer wg.Done() 1999 } 2000 arr1[idx1] = func() graphql.Marshaler { 2001 2002 return ec.___InputValue(ctx, field.Selections, &res[idx1]) 2003 }() 2004 } 2005 if isLen1 { 2006 f(idx1) 2007 } else { 2008 go f(idx1) 2009 } 2010 2011 } 2012 wg.Wait() 2013 return arr1 2014 } 2015 2016 // nolint: vetshadow 2017 func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { 2018 rctx := &graphql.ResolverContext{ 2019 Object: "__Type", 2020 Args: nil, 2021 Field: field, 2022 } 2023 ctx = graphql.WithResolverContext(ctx, rctx) 2024 resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 2025 ctx = rctx // use context from middleware stack in children 2026 return obj.OfType(), nil 2027 }) 2028 if resTmp == nil { 2029 return graphql.Null 2030 } 2031 res := resTmp.(*introspection.Type) 2032 rctx.Result = res 2033 2034 if res == nil { 2035 return graphql.Null 2036 } 2037 2038 return ec.___Type(ctx, field.Selections, res) 2039 } 2040 2041 func UnmarshalNewTodo(v interface{}) (NewTodo, error) { 2042 var it NewTodo 2043 var asMap = v.(map[string]interface{}) 2044 2045 for k, v := range asMap { 2046 switch k { 2047 case "text": 2048 var err error 2049 it.Text, err = graphql.UnmarshalString(v) 2050 if err != nil { 2051 return it, err 2052 } 2053 case "userId": 2054 var err error 2055 it.UserID, err = graphql.UnmarshalString(v) 2056 if err != nil { 2057 return it, err 2058 } 2059 } 2060 } 2061 2062 return it, nil 2063 } 2064 2065 func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { 2066 defer func() { 2067 if r := recover(); r != nil { 2068 ec.Error(ctx, ec.Recover(ctx, r)) 2069 ret = nil 2070 } 2071 }() 2072 res, err := ec.ResolverMiddleware(ctx, next) 2073 if err != nil { 2074 ec.Error(ctx, err) 2075 return nil 2076 } 2077 return res 2078 } 2079 2080 func (ec *executionContext) introspectSchema() *introspection.Schema { 2081 return introspection.WrapSchema(parsedSchema) 2082 } 2083 2084 func (ec *executionContext) introspectType(name string) *introspection.Type { 2085 return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]) 2086 } 2087 2088 var parsedSchema = gqlparser.MustLoadSchema( 2089 &ast.Source{Name: "schema.graphql", Input: `# GraphQL schema example 2090 # 2091 # https://gqlgen.com/getting-started/ 2092 2093 type Todo { 2094 id: ID! 2095 databaseId: Int! 2096 text: String! 2097 done: Boolean! 2098 user: User! 2099 } 2100 2101 type User { 2102 id: ID! 2103 name: String! 2104 } 2105 2106 type Query { 2107 todos: [Todo!]! 2108 } 2109 2110 input NewTodo { 2111 text: String! 2112 userId: String! 2113 } 2114 2115 type Mutation { 2116 createTodo(input: NewTodo!): Todo! 2117 } 2118 `}, 2119 )