github.com/operandinc/gqlgen@v0.16.1/codegen/testserver/followschema/interfaces.generated.go (about) 1 // Code generated by github.com/operandinc/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "fmt" 8 "strconv" 9 "sync" 10 "sync/atomic" 11 12 "github.com/operandinc/gqlgen/graphql" 13 "github.com/vektah/gqlparser/v2/ast" 14 ) 15 16 // region ************************** generated!.gotpl ************************** 17 18 type BackedByInterfaceResolver interface { 19 ID(ctx context.Context, obj BackedByInterface) (string, error) 20 } 21 22 // endregion ************************** generated!.gotpl ************************** 23 24 // region ***************************** args.gotpl ***************************** 25 26 // endregion ***************************** args.gotpl ***************************** 27 28 // region ************************** directives.gotpl ************************** 29 30 // endregion ************************** directives.gotpl ************************** 31 32 // region **************************** field.gotpl ***************************** 33 34 func (ec *executionContext) _BackedByInterface_id(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { 35 defer func() { 36 if r := recover(); r != nil { 37 ec.Error(ctx, ec.Recover(ctx, r)) 38 ret = graphql.Null 39 } 40 }() 41 fc := &graphql.FieldContext{ 42 Object: "BackedByInterface", 43 Field: field, 44 Args: nil, 45 IsMethod: true, 46 IsResolver: true, 47 } 48 49 ctx = graphql.WithFieldContext(ctx, fc) 50 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 51 ctx = rctx // use context from middleware stack in children 52 return ec.resolvers.BackedByInterface().ID(rctx, obj) 53 }) 54 55 if resTmp == nil { 56 if !graphql.HasFieldError(ctx, fc) { 57 ec.Errorf(ctx, "must not be null") 58 } 59 return graphql.Null 60 } 61 res := resTmp.(string) 62 fc.Result = res 63 return ec.marshalNString2string(ctx, field.Selections, res) 64 } 65 66 func (ec *executionContext) _BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { 67 defer func() { 68 if r := recover(); r != nil { 69 ec.Error(ctx, ec.Recover(ctx, r)) 70 ret = graphql.Null 71 } 72 }() 73 fc := &graphql.FieldContext{ 74 Object: "BackedByInterface", 75 Field: field, 76 Args: nil, 77 IsMethod: true, 78 IsResolver: false, 79 } 80 81 ctx = graphql.WithFieldContext(ctx, fc) 82 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 83 ctx = rctx // use context from middleware stack in children 84 return obj.ThisShouldBind(), nil 85 }) 86 87 if resTmp == nil { 88 if !graphql.HasFieldError(ctx, fc) { 89 ec.Errorf(ctx, "must not be null") 90 } 91 return graphql.Null 92 } 93 res := resTmp.(string) 94 fc.Result = res 95 return ec.marshalNString2string(ctx, field.Selections, res) 96 } 97 98 func (ec *executionContext) _BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { 99 defer func() { 100 if r := recover(); r != nil { 101 ec.Error(ctx, ec.Recover(ctx, r)) 102 ret = graphql.Null 103 } 104 }() 105 fc := &graphql.FieldContext{ 106 Object: "BackedByInterface", 107 Field: field, 108 Args: nil, 109 IsMethod: true, 110 IsResolver: false, 111 } 112 113 ctx = graphql.WithFieldContext(ctx, fc) 114 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 115 ctx = rctx // use context from middleware stack in children 116 return obj.ThisShouldBindWithError() 117 }) 118 119 if resTmp == nil { 120 if !graphql.HasFieldError(ctx, fc) { 121 ec.Errorf(ctx, "must not be null") 122 } 123 return graphql.Null 124 } 125 res := resTmp.(string) 126 fc.Result = res 127 return ec.marshalNString2string(ctx, field.Selections, res) 128 } 129 130 func (ec *executionContext) _Cat_species(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { 131 defer func() { 132 if r := recover(); r != nil { 133 ec.Error(ctx, ec.Recover(ctx, r)) 134 ret = graphql.Null 135 } 136 }() 137 fc := &graphql.FieldContext{ 138 Object: "Cat", 139 Field: field, 140 Args: nil, 141 IsMethod: false, 142 IsResolver: false, 143 } 144 145 ctx = graphql.WithFieldContext(ctx, fc) 146 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 147 ctx = rctx // use context from middleware stack in children 148 return obj.Species, nil 149 }) 150 151 if resTmp == nil { 152 if !graphql.HasFieldError(ctx, fc) { 153 ec.Errorf(ctx, "must not be null") 154 } 155 return graphql.Null 156 } 157 res := resTmp.(string) 158 fc.Result = res 159 return ec.marshalNString2string(ctx, field.Selections, res) 160 } 161 162 func (ec *executionContext) _Cat_catBreed(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { 163 defer func() { 164 if r := recover(); r != nil { 165 ec.Error(ctx, ec.Recover(ctx, r)) 166 ret = graphql.Null 167 } 168 }() 169 fc := &graphql.FieldContext{ 170 Object: "Cat", 171 Field: field, 172 Args: nil, 173 IsMethod: false, 174 IsResolver: false, 175 } 176 177 ctx = graphql.WithFieldContext(ctx, fc) 178 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 179 ctx = rctx // use context from middleware stack in children 180 return obj.CatBreed, nil 181 }) 182 183 if resTmp == nil { 184 if !graphql.HasFieldError(ctx, fc) { 185 ec.Errorf(ctx, "must not be null") 186 } 187 return graphql.Null 188 } 189 res := resTmp.(string) 190 fc.Result = res 191 return ec.marshalNString2string(ctx, field.Selections, res) 192 } 193 194 func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { 195 defer func() { 196 if r := recover(); r != nil { 197 ec.Error(ctx, ec.Recover(ctx, r)) 198 ret = graphql.Null 199 } 200 }() 201 fc := &graphql.FieldContext{ 202 Object: "Circle", 203 Field: field, 204 Args: nil, 205 IsMethod: false, 206 IsResolver: false, 207 } 208 209 ctx = graphql.WithFieldContext(ctx, fc) 210 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 211 ctx = rctx // use context from middleware stack in children 212 return obj.Radius, nil 213 }) 214 215 if resTmp == nil { 216 return graphql.Null 217 } 218 res := resTmp.(float64) 219 fc.Result = res 220 return ec.marshalOFloat2float64(ctx, field.Selections, res) 221 } 222 223 func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { 224 defer func() { 225 if r := recover(); r != nil { 226 ec.Error(ctx, ec.Recover(ctx, r)) 227 ret = graphql.Null 228 } 229 }() 230 fc := &graphql.FieldContext{ 231 Object: "Circle", 232 Field: field, 233 Args: nil, 234 IsMethod: true, 235 IsResolver: false, 236 } 237 238 ctx = graphql.WithFieldContext(ctx, fc) 239 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 240 ctx = rctx // use context from middleware stack in children 241 return obj.Area(), nil 242 }) 243 244 if resTmp == nil { 245 return graphql.Null 246 } 247 res := resTmp.(float64) 248 fc.Result = res 249 return ec.marshalOFloat2float64(ctx, field.Selections, res) 250 } 251 252 func (ec *executionContext) _Circle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { 253 defer func() { 254 if r := recover(); r != nil { 255 ec.Error(ctx, ec.Recover(ctx, r)) 256 ret = graphql.Null 257 } 258 }() 259 fc := &graphql.FieldContext{ 260 Object: "Circle", 261 Field: field, 262 Args: nil, 263 IsMethod: false, 264 IsResolver: false, 265 } 266 267 ctx = graphql.WithFieldContext(ctx, fc) 268 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 269 ctx = rctx // use context from middleware stack in children 270 return obj.Coordinates, nil 271 }) 272 273 if resTmp == nil { 274 return graphql.Null 275 } 276 res := resTmp.(Coordinates) 277 fc.Result = res 278 return ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx, field.Selections, res) 279 } 280 281 func (ec *executionContext) _ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { 282 defer func() { 283 if r := recover(); r != nil { 284 ec.Error(ctx, ec.Recover(ctx, r)) 285 ret = graphql.Null 286 } 287 }() 288 fc := &graphql.FieldContext{ 289 Object: "ConcreteNodeA", 290 Field: field, 291 Args: nil, 292 IsMethod: false, 293 IsResolver: false, 294 } 295 296 ctx = graphql.WithFieldContext(ctx, fc) 297 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 298 ctx = rctx // use context from middleware stack in children 299 return obj.ID, nil 300 }) 301 302 if resTmp == nil { 303 if !graphql.HasFieldError(ctx, fc) { 304 ec.Errorf(ctx, "must not be null") 305 } 306 return graphql.Null 307 } 308 res := resTmp.(string) 309 fc.Result = res 310 return ec.marshalNID2string(ctx, field.Selections, res) 311 } 312 313 func (ec *executionContext) _ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { 314 defer func() { 315 if r := recover(); r != nil { 316 ec.Error(ctx, ec.Recover(ctx, r)) 317 ret = graphql.Null 318 } 319 }() 320 fc := &graphql.FieldContext{ 321 Object: "ConcreteNodeA", 322 Field: field, 323 Args: nil, 324 IsMethod: true, 325 IsResolver: false, 326 } 327 328 ctx = graphql.WithFieldContext(ctx, fc) 329 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 330 ctx = rctx // use context from middleware stack in children 331 return obj.Child() 332 }) 333 334 if resTmp == nil { 335 if !graphql.HasFieldError(ctx, fc) { 336 ec.Errorf(ctx, "must not be null") 337 } 338 return graphql.Null 339 } 340 res := resTmp.(Node) 341 fc.Result = res 342 return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res) 343 } 344 345 func (ec *executionContext) _ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { 346 defer func() { 347 if r := recover(); r != nil { 348 ec.Error(ctx, ec.Recover(ctx, r)) 349 ret = graphql.Null 350 } 351 }() 352 fc := &graphql.FieldContext{ 353 Object: "ConcreteNodeA", 354 Field: field, 355 Args: nil, 356 IsMethod: false, 357 IsResolver: false, 358 } 359 360 ctx = graphql.WithFieldContext(ctx, fc) 361 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 362 ctx = rctx // use context from middleware stack in children 363 return obj.Name, nil 364 }) 365 366 if resTmp == nil { 367 if !graphql.HasFieldError(ctx, fc) { 368 ec.Errorf(ctx, "must not be null") 369 } 370 return graphql.Null 371 } 372 res := resTmp.(string) 373 fc.Result = res 374 return ec.marshalNString2string(ctx, field.Selections, res) 375 } 376 377 func (ec *executionContext) _ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { 378 defer func() { 379 if r := recover(); r != nil { 380 ec.Error(ctx, ec.Recover(ctx, r)) 381 ret = graphql.Null 382 } 383 }() 384 fc := &graphql.FieldContext{ 385 Object: "ConcreteNodeInterface", 386 Field: field, 387 Args: nil, 388 IsMethod: true, 389 IsResolver: false, 390 } 391 392 ctx = graphql.WithFieldContext(ctx, fc) 393 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 394 ctx = rctx // use context from middleware stack in children 395 return obj.ID(), nil 396 }) 397 398 if resTmp == nil { 399 if !graphql.HasFieldError(ctx, fc) { 400 ec.Errorf(ctx, "must not be null") 401 } 402 return graphql.Null 403 } 404 res := resTmp.(string) 405 fc.Result = res 406 return ec.marshalNID2string(ctx, field.Selections, res) 407 } 408 409 func (ec *executionContext) _ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { 410 defer func() { 411 if r := recover(); r != nil { 412 ec.Error(ctx, ec.Recover(ctx, r)) 413 ret = graphql.Null 414 } 415 }() 416 fc := &graphql.FieldContext{ 417 Object: "ConcreteNodeInterface", 418 Field: field, 419 Args: nil, 420 IsMethod: true, 421 IsResolver: false, 422 } 423 424 ctx = graphql.WithFieldContext(ctx, fc) 425 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 426 ctx = rctx // use context from middleware stack in children 427 return obj.Child() 428 }) 429 430 if resTmp == nil { 431 if !graphql.HasFieldError(ctx, fc) { 432 ec.Errorf(ctx, "must not be null") 433 } 434 return graphql.Null 435 } 436 res := resTmp.(Node) 437 fc.Result = res 438 return ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res) 439 } 440 441 func (ec *executionContext) _Coordinates_x(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { 442 defer func() { 443 if r := recover(); r != nil { 444 ec.Error(ctx, ec.Recover(ctx, r)) 445 ret = graphql.Null 446 } 447 }() 448 fc := &graphql.FieldContext{ 449 Object: "Coordinates", 450 Field: field, 451 Args: nil, 452 IsMethod: false, 453 IsResolver: false, 454 } 455 456 ctx = graphql.WithFieldContext(ctx, fc) 457 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 458 ctx = rctx // use context from middleware stack in children 459 return obj.X, nil 460 }) 461 462 if resTmp == nil { 463 if !graphql.HasFieldError(ctx, fc) { 464 ec.Errorf(ctx, "must not be null") 465 } 466 return graphql.Null 467 } 468 res := resTmp.(float64) 469 fc.Result = res 470 return ec.marshalNFloat2float64(ctx, field.Selections, res) 471 } 472 473 func (ec *executionContext) _Coordinates_y(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { 474 defer func() { 475 if r := recover(); r != nil { 476 ec.Error(ctx, ec.Recover(ctx, r)) 477 ret = graphql.Null 478 } 479 }() 480 fc := &graphql.FieldContext{ 481 Object: "Coordinates", 482 Field: field, 483 Args: nil, 484 IsMethod: false, 485 IsResolver: false, 486 } 487 488 ctx = graphql.WithFieldContext(ctx, fc) 489 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 490 ctx = rctx // use context from middleware stack in children 491 return obj.Y, nil 492 }) 493 494 if resTmp == nil { 495 if !graphql.HasFieldError(ctx, fc) { 496 ec.Errorf(ctx, "must not be null") 497 } 498 return graphql.Null 499 } 500 res := resTmp.(float64) 501 fc.Result = res 502 return ec.marshalNFloat2float64(ctx, field.Selections, res) 503 } 504 505 func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { 506 defer func() { 507 if r := recover(); r != nil { 508 ec.Error(ctx, ec.Recover(ctx, r)) 509 ret = graphql.Null 510 } 511 }() 512 fc := &graphql.FieldContext{ 513 Object: "Dog", 514 Field: field, 515 Args: nil, 516 IsMethod: false, 517 IsResolver: false, 518 } 519 520 ctx = graphql.WithFieldContext(ctx, fc) 521 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 522 ctx = rctx // use context from middleware stack in children 523 return obj.Species, nil 524 }) 525 526 if resTmp == nil { 527 if !graphql.HasFieldError(ctx, fc) { 528 ec.Errorf(ctx, "must not be null") 529 } 530 return graphql.Null 531 } 532 res := resTmp.(string) 533 fc.Result = res 534 return ec.marshalNString2string(ctx, field.Selections, res) 535 } 536 537 func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { 538 defer func() { 539 if r := recover(); r != nil { 540 ec.Error(ctx, ec.Recover(ctx, r)) 541 ret = graphql.Null 542 } 543 }() 544 fc := &graphql.FieldContext{ 545 Object: "Dog", 546 Field: field, 547 Args: nil, 548 IsMethod: false, 549 IsResolver: false, 550 } 551 552 ctx = graphql.WithFieldContext(ctx, fc) 553 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 554 ctx = rctx // use context from middleware stack in children 555 return obj.DogBreed, nil 556 }) 557 558 if resTmp == nil { 559 if !graphql.HasFieldError(ctx, fc) { 560 ec.Errorf(ctx, "must not be null") 561 } 562 return graphql.Null 563 } 564 res := resTmp.(string) 565 fc.Result = res 566 return ec.marshalNString2string(ctx, field.Selections, res) 567 } 568 569 func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { 570 defer func() { 571 if r := recover(); r != nil { 572 ec.Error(ctx, ec.Recover(ctx, r)) 573 ret = graphql.Null 574 } 575 }() 576 fc := &graphql.FieldContext{ 577 Object: "Rectangle", 578 Field: field, 579 Args: nil, 580 IsMethod: false, 581 IsResolver: false, 582 } 583 584 ctx = graphql.WithFieldContext(ctx, fc) 585 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 586 ctx = rctx // use context from middleware stack in children 587 return obj.Length, nil 588 }) 589 590 if resTmp == nil { 591 return graphql.Null 592 } 593 res := resTmp.(float64) 594 fc.Result = res 595 return ec.marshalOFloat2float64(ctx, field.Selections, res) 596 } 597 598 func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { 599 defer func() { 600 if r := recover(); r != nil { 601 ec.Error(ctx, ec.Recover(ctx, r)) 602 ret = graphql.Null 603 } 604 }() 605 fc := &graphql.FieldContext{ 606 Object: "Rectangle", 607 Field: field, 608 Args: nil, 609 IsMethod: false, 610 IsResolver: false, 611 } 612 613 ctx = graphql.WithFieldContext(ctx, fc) 614 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 615 ctx = rctx // use context from middleware stack in children 616 return obj.Width, nil 617 }) 618 619 if resTmp == nil { 620 return graphql.Null 621 } 622 res := resTmp.(float64) 623 fc.Result = res 624 return ec.marshalOFloat2float64(ctx, field.Selections, res) 625 } 626 627 func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { 628 defer func() { 629 if r := recover(); r != nil { 630 ec.Error(ctx, ec.Recover(ctx, r)) 631 ret = graphql.Null 632 } 633 }() 634 fc := &graphql.FieldContext{ 635 Object: "Rectangle", 636 Field: field, 637 Args: nil, 638 IsMethod: true, 639 IsResolver: false, 640 } 641 642 ctx = graphql.WithFieldContext(ctx, fc) 643 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 644 ctx = rctx // use context from middleware stack in children 645 return obj.Area(), nil 646 }) 647 648 if resTmp == nil { 649 return graphql.Null 650 } 651 res := resTmp.(float64) 652 fc.Result = res 653 return ec.marshalOFloat2float64(ctx, field.Selections, res) 654 } 655 656 func (ec *executionContext) _Rectangle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { 657 defer func() { 658 if r := recover(); r != nil { 659 ec.Error(ctx, ec.Recover(ctx, r)) 660 ret = graphql.Null 661 } 662 }() 663 fc := &graphql.FieldContext{ 664 Object: "Rectangle", 665 Field: field, 666 Args: nil, 667 IsMethod: false, 668 IsResolver: false, 669 } 670 671 ctx = graphql.WithFieldContext(ctx, fc) 672 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 673 ctx = rctx // use context from middleware stack in children 674 return obj.Coordinates, nil 675 }) 676 677 if resTmp == nil { 678 return graphql.Null 679 } 680 res := resTmp.(Coordinates) 681 fc.Result = res 682 return ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx, field.Selections, res) 683 } 684 685 // endregion **************************** field.gotpl ***************************** 686 687 // region **************************** input.gotpl ***************************** 688 689 // endregion **************************** input.gotpl ***************************** 690 691 // region ************************** interface.gotpl *************************** 692 693 func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, obj Animal) graphql.Marshaler { 694 switch obj := (obj).(type) { 695 case nil: 696 return graphql.Null 697 case Dog: 698 return ec._Dog(ctx, sel, &obj) 699 case *Dog: 700 if obj == nil { 701 return graphql.Null 702 } 703 return ec._Dog(ctx, sel, obj) 704 case Cat: 705 return ec._Cat(ctx, sel, &obj) 706 case *Cat: 707 if obj == nil { 708 return graphql.Null 709 } 710 return ec._Cat(ctx, sel, obj) 711 default: 712 panic(fmt.Errorf("unexpected type %T", obj)) 713 } 714 } 715 716 func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj Node) graphql.Marshaler { 717 switch obj := (obj).(type) { 718 case nil: 719 return graphql.Null 720 case *ConcreteNodeA: 721 if obj == nil { 722 return graphql.Null 723 } 724 return ec._ConcreteNodeA(ctx, sel, obj) 725 case ConcreteNodeInterface: 726 if obj == nil { 727 return graphql.Null 728 } 729 return ec._ConcreteNodeInterface(ctx, sel, obj) 730 default: 731 panic(fmt.Errorf("unexpected type %T", obj)) 732 } 733 } 734 735 func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, obj Shape) graphql.Marshaler { 736 switch obj := (obj).(type) { 737 case nil: 738 return graphql.Null 739 case *Circle: 740 if obj == nil { 741 return graphql.Null 742 } 743 return ec._Circle(ctx, sel, obj) 744 case *Rectangle: 745 if obj == nil { 746 return graphql.Null 747 } 748 return ec._Rectangle(ctx, sel, obj) 749 default: 750 panic(fmt.Errorf("unexpected type %T", obj)) 751 } 752 } 753 754 func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSet, obj ShapeUnion) graphql.Marshaler { 755 switch obj := (obj).(type) { 756 case nil: 757 return graphql.Null 758 case *Circle: 759 if obj == nil { 760 return graphql.Null 761 } 762 return ec._Circle(ctx, sel, obj) 763 case *Rectangle: 764 if obj == nil { 765 return graphql.Null 766 } 767 return ec._Rectangle(ctx, sel, obj) 768 default: 769 panic(fmt.Errorf("unexpected type %T", obj)) 770 } 771 } 772 773 // endregion ************************** interface.gotpl *************************** 774 775 // region **************************** object.gotpl **************************** 776 777 var backedByInterfaceImplementors = []string{"BackedByInterface"} 778 779 func (ec *executionContext) _BackedByInterface(ctx context.Context, sel ast.SelectionSet, obj BackedByInterface) graphql.Marshaler { 780 fields := graphql.CollectFields(ec.OperationContext, sel, backedByInterfaceImplementors) 781 out := graphql.NewFieldSet(fields) 782 var invalids uint32 783 for i, field := range fields { 784 switch field.Name { 785 case "__typename": 786 out.Values[i] = graphql.MarshalString("BackedByInterface") 787 case "id": 788 field := field 789 790 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 791 defer func() { 792 if r := recover(); r != nil { 793 ec.Error(ctx, ec.Recover(ctx, r)) 794 } 795 }() 796 res = ec._BackedByInterface_id(ctx, field, obj) 797 if res == graphql.Null { 798 atomic.AddUint32(&invalids, 1) 799 } 800 return res 801 } 802 803 out.Concurrently(i, func() graphql.Marshaler { 804 return innerFunc(ctx) 805 806 }) 807 case "thisShouldBind": 808 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 809 return ec._BackedByInterface_thisShouldBind(ctx, field, obj) 810 } 811 812 out.Values[i] = innerFunc(ctx) 813 814 if out.Values[i] == graphql.Null { 815 atomic.AddUint32(&invalids, 1) 816 } 817 case "thisShouldBindWithError": 818 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 819 return ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj) 820 } 821 822 out.Values[i] = innerFunc(ctx) 823 824 if out.Values[i] == graphql.Null { 825 atomic.AddUint32(&invalids, 1) 826 } 827 default: 828 panic("unknown field " + strconv.Quote(field.Name)) 829 } 830 } 831 out.Dispatch() 832 if invalids > 0 { 833 return graphql.Null 834 } 835 return out 836 } 837 838 var catImplementors = []string{"Cat", "Animal"} 839 840 func (ec *executionContext) _Cat(ctx context.Context, sel ast.SelectionSet, obj *Cat) graphql.Marshaler { 841 fields := graphql.CollectFields(ec.OperationContext, sel, catImplementors) 842 out := graphql.NewFieldSet(fields) 843 var invalids uint32 844 for i, field := range fields { 845 switch field.Name { 846 case "__typename": 847 out.Values[i] = graphql.MarshalString("Cat") 848 case "species": 849 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 850 return ec._Cat_species(ctx, field, obj) 851 } 852 853 out.Values[i] = innerFunc(ctx) 854 855 if out.Values[i] == graphql.Null { 856 invalids++ 857 } 858 case "catBreed": 859 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 860 return ec._Cat_catBreed(ctx, field, obj) 861 } 862 863 out.Values[i] = innerFunc(ctx) 864 865 if out.Values[i] == graphql.Null { 866 invalids++ 867 } 868 default: 869 panic("unknown field " + strconv.Quote(field.Name)) 870 } 871 } 872 out.Dispatch() 873 if invalids > 0 { 874 return graphql.Null 875 } 876 return out 877 } 878 879 var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} 880 881 func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { 882 fields := graphql.CollectFields(ec.OperationContext, sel, circleImplementors) 883 out := graphql.NewFieldSet(fields) 884 var invalids uint32 885 for i, field := range fields { 886 switch field.Name { 887 case "__typename": 888 out.Values[i] = graphql.MarshalString("Circle") 889 case "radius": 890 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 891 return ec._Circle_radius(ctx, field, obj) 892 } 893 894 out.Values[i] = innerFunc(ctx) 895 896 case "area": 897 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 898 return ec._Circle_area(ctx, field, obj) 899 } 900 901 out.Values[i] = innerFunc(ctx) 902 903 case "coordinates": 904 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 905 return ec._Circle_coordinates(ctx, field, obj) 906 } 907 908 out.Values[i] = innerFunc(ctx) 909 910 default: 911 panic("unknown field " + strconv.Quote(field.Name)) 912 } 913 } 914 out.Dispatch() 915 if invalids > 0 { 916 return graphql.Null 917 } 918 return out 919 } 920 921 var concreteNodeAImplementors = []string{"ConcreteNodeA", "Node"} 922 923 func (ec *executionContext) _ConcreteNodeA(ctx context.Context, sel ast.SelectionSet, obj *ConcreteNodeA) graphql.Marshaler { 924 fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeAImplementors) 925 out := graphql.NewFieldSet(fields) 926 var invalids uint32 927 for i, field := range fields { 928 switch field.Name { 929 case "__typename": 930 out.Values[i] = graphql.MarshalString("ConcreteNodeA") 931 case "id": 932 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 933 return ec._ConcreteNodeA_id(ctx, field, obj) 934 } 935 936 out.Values[i] = innerFunc(ctx) 937 938 if out.Values[i] == graphql.Null { 939 invalids++ 940 } 941 case "child": 942 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 943 return ec._ConcreteNodeA_child(ctx, field, obj) 944 } 945 946 out.Values[i] = innerFunc(ctx) 947 948 if out.Values[i] == graphql.Null { 949 invalids++ 950 } 951 case "name": 952 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 953 return ec._ConcreteNodeA_name(ctx, field, obj) 954 } 955 956 out.Values[i] = innerFunc(ctx) 957 958 if out.Values[i] == graphql.Null { 959 invalids++ 960 } 961 default: 962 panic("unknown field " + strconv.Quote(field.Name)) 963 } 964 } 965 out.Dispatch() 966 if invalids > 0 { 967 return graphql.Null 968 } 969 return out 970 } 971 972 var concreteNodeInterfaceImplementors = []string{"ConcreteNodeInterface", "Node"} 973 974 func (ec *executionContext) _ConcreteNodeInterface(ctx context.Context, sel ast.SelectionSet, obj ConcreteNodeInterface) graphql.Marshaler { 975 fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeInterfaceImplementors) 976 out := graphql.NewFieldSet(fields) 977 var invalids uint32 978 for i, field := range fields { 979 switch field.Name { 980 case "__typename": 981 out.Values[i] = graphql.MarshalString("ConcreteNodeInterface") 982 case "id": 983 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 984 return ec._ConcreteNodeInterface_id(ctx, field, obj) 985 } 986 987 out.Values[i] = innerFunc(ctx) 988 989 if out.Values[i] == graphql.Null { 990 invalids++ 991 } 992 case "child": 993 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 994 return ec._ConcreteNodeInterface_child(ctx, field, obj) 995 } 996 997 out.Values[i] = innerFunc(ctx) 998 999 if out.Values[i] == graphql.Null { 1000 invalids++ 1001 } 1002 default: 1003 panic("unknown field " + strconv.Quote(field.Name)) 1004 } 1005 } 1006 out.Dispatch() 1007 if invalids > 0 { 1008 return graphql.Null 1009 } 1010 return out 1011 } 1012 1013 var coordinatesImplementors = []string{"Coordinates"} 1014 1015 func (ec *executionContext) _Coordinates(ctx context.Context, sel ast.SelectionSet, obj *Coordinates) graphql.Marshaler { 1016 fields := graphql.CollectFields(ec.OperationContext, sel, coordinatesImplementors) 1017 out := graphql.NewFieldSet(fields) 1018 var invalids uint32 1019 for i, field := range fields { 1020 switch field.Name { 1021 case "__typename": 1022 out.Values[i] = graphql.MarshalString("Coordinates") 1023 case "x": 1024 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1025 return ec._Coordinates_x(ctx, field, obj) 1026 } 1027 1028 out.Values[i] = innerFunc(ctx) 1029 1030 if out.Values[i] == graphql.Null { 1031 invalids++ 1032 } 1033 case "y": 1034 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1035 return ec._Coordinates_y(ctx, field, obj) 1036 } 1037 1038 out.Values[i] = innerFunc(ctx) 1039 1040 if out.Values[i] == graphql.Null { 1041 invalids++ 1042 } 1043 default: 1044 panic("unknown field " + strconv.Quote(field.Name)) 1045 } 1046 } 1047 out.Dispatch() 1048 if invalids > 0 { 1049 return graphql.Null 1050 } 1051 return out 1052 } 1053 1054 var dogImplementors = []string{"Dog", "Animal"} 1055 1056 func (ec *executionContext) _Dog(ctx context.Context, sel ast.SelectionSet, obj *Dog) graphql.Marshaler { 1057 fields := graphql.CollectFields(ec.OperationContext, sel, dogImplementors) 1058 out := graphql.NewFieldSet(fields) 1059 var invalids uint32 1060 for i, field := range fields { 1061 switch field.Name { 1062 case "__typename": 1063 out.Values[i] = graphql.MarshalString("Dog") 1064 case "species": 1065 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1066 return ec._Dog_species(ctx, field, obj) 1067 } 1068 1069 out.Values[i] = innerFunc(ctx) 1070 1071 if out.Values[i] == graphql.Null { 1072 invalids++ 1073 } 1074 case "dogBreed": 1075 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1076 return ec._Dog_dogBreed(ctx, field, obj) 1077 } 1078 1079 out.Values[i] = innerFunc(ctx) 1080 1081 if out.Values[i] == graphql.Null { 1082 invalids++ 1083 } 1084 default: 1085 panic("unknown field " + strconv.Quote(field.Name)) 1086 } 1087 } 1088 out.Dispatch() 1089 if invalids > 0 { 1090 return graphql.Null 1091 } 1092 return out 1093 } 1094 1095 var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"} 1096 1097 func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { 1098 fields := graphql.CollectFields(ec.OperationContext, sel, rectangleImplementors) 1099 out := graphql.NewFieldSet(fields) 1100 var invalids uint32 1101 for i, field := range fields { 1102 switch field.Name { 1103 case "__typename": 1104 out.Values[i] = graphql.MarshalString("Rectangle") 1105 case "length": 1106 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1107 return ec._Rectangle_length(ctx, field, obj) 1108 } 1109 1110 out.Values[i] = innerFunc(ctx) 1111 1112 case "width": 1113 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1114 return ec._Rectangle_width(ctx, field, obj) 1115 } 1116 1117 out.Values[i] = innerFunc(ctx) 1118 1119 case "area": 1120 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1121 return ec._Rectangle_area(ctx, field, obj) 1122 } 1123 1124 out.Values[i] = innerFunc(ctx) 1125 1126 case "coordinates": 1127 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1128 return ec._Rectangle_coordinates(ctx, field, obj) 1129 } 1130 1131 out.Values[i] = innerFunc(ctx) 1132 1133 default: 1134 panic("unknown field " + strconv.Quote(field.Name)) 1135 } 1136 } 1137 out.Dispatch() 1138 if invalids > 0 { 1139 return graphql.Null 1140 } 1141 return out 1142 } 1143 1144 // endregion **************************** object.gotpl **************************** 1145 1146 // region ***************************** type.gotpl ***************************** 1147 1148 func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler { 1149 if v == nil { 1150 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1151 ec.Errorf(ctx, "must not be null") 1152 } 1153 return graphql.Null 1154 } 1155 return ec._Node(ctx, sel, v) 1156 } 1157 1158 func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler { 1159 if v == nil { 1160 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1161 ec.Errorf(ctx, "must not be null") 1162 } 1163 return graphql.Null 1164 } 1165 return ec._ShapeUnion(ctx, sel, v) 1166 } 1167 1168 func (ec *executionContext) marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAnimal(ctx context.Context, sel ast.SelectionSet, v Animal) graphql.Marshaler { 1169 if v == nil { 1170 return graphql.Null 1171 } 1172 return ec._Animal(ctx, sel, v) 1173 } 1174 1175 func (ec *executionContext) marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐBackedByInterface(ctx context.Context, sel ast.SelectionSet, v BackedByInterface) graphql.Marshaler { 1176 if v == nil { 1177 return graphql.Null 1178 } 1179 return ec._BackedByInterface(ctx, sel, v) 1180 } 1181 1182 func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { 1183 if v == nil { 1184 return graphql.Null 1185 } 1186 return ec._Circle(ctx, sel, v) 1187 } 1188 1189 func (ec *executionContext) marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler { 1190 return ec._Coordinates(ctx, sel, &v) 1191 } 1192 1193 func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { 1194 if v == nil { 1195 return graphql.Null 1196 } 1197 return ec._Shape(ctx, sel, v) 1198 } 1199 1200 func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { 1201 if v == nil { 1202 return graphql.Null 1203 } 1204 ret := make(graphql.Array, len(v)) 1205 var wg sync.WaitGroup 1206 isLen1 := len(v) == 1 1207 if !isLen1 { 1208 wg.Add(len(v)) 1209 } 1210 for i := range v { 1211 i := i 1212 fc := &graphql.FieldContext{ 1213 Index: &i, 1214 Result: &v[i], 1215 } 1216 ctx := graphql.WithFieldContext(ctx, fc) 1217 f := func(i int) { 1218 defer func() { 1219 if r := recover(); r != nil { 1220 ec.Error(ctx, ec.Recover(ctx, r)) 1221 ret = nil 1222 } 1223 }() 1224 if !isLen1 { 1225 defer wg.Done() 1226 } 1227 ret[i] = ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, sel, v[i]) 1228 } 1229 if isLen1 { 1230 f(i) 1231 } else { 1232 go f(i) 1233 } 1234 1235 } 1236 wg.Wait() 1237 1238 return ret 1239 } 1240 1241 // endregion ***************************** type.gotpl *****************************