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