github.com/geneva/gqlgen@v0.17.7-0.20230801155730-7b9317164836/codegen/testserver/followschema/interfaces.generated.go (about) 1 // Code generated by github.com/geneva/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "errors" 8 "fmt" 9 "strconv" 10 "sync" 11 "sync/atomic" 12 13 "github.com/geneva/gqlgen/graphql" 14 "github.com/vektah/gqlparser/v2/ast" 15 ) 16 17 // region ************************** generated!.gotpl ************************** 18 19 type BackedByInterfaceResolver interface { 20 ID(ctx context.Context, obj BackedByInterface) (string, error) 21 } 22 23 // endregion ************************** generated!.gotpl ************************** 24 25 // region ***************************** args.gotpl ***************************** 26 27 // endregion ***************************** args.gotpl ***************************** 28 29 // region ************************** directives.gotpl ************************** 30 31 // endregion ************************** directives.gotpl ************************** 32 33 // region **************************** field.gotpl ***************************** 34 35 func (ec *executionContext) _BackedByInterface_id(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { 36 fc, err := ec.fieldContext_BackedByInterface_id(ctx, field) 37 if err != nil { 38 return graphql.Null 39 } 40 ctx = graphql.WithFieldContext(ctx, fc) 41 defer func() { 42 if r := recover(); r != nil { 43 ec.Error(ctx, ec.Recover(ctx, r)) 44 ret = graphql.Null 45 } 46 }() 47 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 48 ctx = rctx // use context from middleware stack in children 49 return ec.resolvers.BackedByInterface().ID(rctx, obj) 50 }) 51 52 if resTmp == nil { 53 if !graphql.HasFieldError(ctx, fc) { 54 ec.Errorf(ctx, "must not be null") 55 } 56 return graphql.Null 57 } 58 res := resTmp.(string) 59 fc.Result = res 60 return ec.marshalNString2string(ctx, field.Selections, res) 61 } 62 63 func (ec *executionContext) fieldContext_BackedByInterface_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 64 fc = &graphql.FieldContext{ 65 Object: "BackedByInterface", 66 Field: field, 67 IsMethod: true, 68 IsResolver: true, 69 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 70 return nil, errors.New("field of type String does not have child fields") 71 }, 72 } 73 return fc, nil 74 } 75 76 func (ec *executionContext) _BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { 77 fc, err := ec.fieldContext_BackedByInterface_thisShouldBind(ctx, field) 78 if err != nil { 79 return graphql.Null 80 } 81 ctx = graphql.WithFieldContext(ctx, fc) 82 defer func() { 83 if r := recover(); r != nil { 84 ec.Error(ctx, ec.Recover(ctx, r)) 85 ret = graphql.Null 86 } 87 }() 88 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 89 ctx = rctx // use context from middleware stack in children 90 return obj.ThisShouldBind(), nil 91 }) 92 93 if resTmp == nil { 94 if !graphql.HasFieldError(ctx, fc) { 95 ec.Errorf(ctx, "must not be null") 96 } 97 return graphql.Null 98 } 99 res := resTmp.(string) 100 fc.Result = res 101 return ec.marshalNString2string(ctx, field.Selections, res) 102 } 103 104 func (ec *executionContext) fieldContext_BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 105 fc = &graphql.FieldContext{ 106 Object: "BackedByInterface", 107 Field: field, 108 IsMethod: true, 109 IsResolver: false, 110 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 111 return nil, errors.New("field of type String does not have child fields") 112 }, 113 } 114 return fc, nil 115 } 116 117 func (ec *executionContext) _BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { 118 fc, err := ec.fieldContext_BackedByInterface_thisShouldBindWithError(ctx, field) 119 if err != nil { 120 return graphql.Null 121 } 122 ctx = graphql.WithFieldContext(ctx, fc) 123 defer func() { 124 if r := recover(); r != nil { 125 ec.Error(ctx, ec.Recover(ctx, r)) 126 ret = graphql.Null 127 } 128 }() 129 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 130 ctx = rctx // use context from middleware stack in children 131 return obj.ThisShouldBindWithError() 132 }) 133 134 if resTmp == nil { 135 if !graphql.HasFieldError(ctx, fc) { 136 ec.Errorf(ctx, "must not be null") 137 } 138 return graphql.Null 139 } 140 res := resTmp.(string) 141 fc.Result = res 142 return ec.marshalNString2string(ctx, field.Selections, res) 143 } 144 145 func (ec *executionContext) fieldContext_BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 146 fc = &graphql.FieldContext{ 147 Object: "BackedByInterface", 148 Field: field, 149 IsMethod: true, 150 IsResolver: false, 151 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 152 return nil, errors.New("field of type String does not have child fields") 153 }, 154 } 155 return fc, nil 156 } 157 158 func (ec *executionContext) _Cat_species(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { 159 fc, err := ec.fieldContext_Cat_species(ctx, field) 160 if err != nil { 161 return graphql.Null 162 } 163 ctx = graphql.WithFieldContext(ctx, fc) 164 defer func() { 165 if r := recover(); r != nil { 166 ec.Error(ctx, ec.Recover(ctx, r)) 167 ret = graphql.Null 168 } 169 }() 170 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 171 ctx = rctx // use context from middleware stack in children 172 return obj.Species, nil 173 }) 174 175 if resTmp == nil { 176 if !graphql.HasFieldError(ctx, fc) { 177 ec.Errorf(ctx, "must not be null") 178 } 179 return graphql.Null 180 } 181 res := resTmp.(string) 182 fc.Result = res 183 return ec.marshalNString2string(ctx, field.Selections, res) 184 } 185 186 func (ec *executionContext) fieldContext_Cat_species(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 187 fc = &graphql.FieldContext{ 188 Object: "Cat", 189 Field: field, 190 IsMethod: false, 191 IsResolver: false, 192 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 193 return nil, errors.New("field of type String does not have child fields") 194 }, 195 } 196 return fc, nil 197 } 198 199 func (ec *executionContext) _Cat_size(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { 200 fc, err := ec.fieldContext_Cat_size(ctx, field) 201 if err != nil { 202 return graphql.Null 203 } 204 ctx = graphql.WithFieldContext(ctx, fc) 205 defer func() { 206 if r := recover(); r != nil { 207 ec.Error(ctx, ec.Recover(ctx, r)) 208 ret = graphql.Null 209 } 210 }() 211 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 212 ctx = rctx // use context from middleware stack in children 213 return obj.Size, nil 214 }) 215 216 if resTmp == nil { 217 if !graphql.HasFieldError(ctx, fc) { 218 ec.Errorf(ctx, "must not be null") 219 } 220 return graphql.Null 221 } 222 res := resTmp.(*Size) 223 fc.Result = res 224 return ec.marshalNSize2ᚖgithubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx, field.Selections, res) 225 } 226 227 func (ec *executionContext) fieldContext_Cat_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 228 fc = &graphql.FieldContext{ 229 Object: "Cat", 230 Field: field, 231 IsMethod: false, 232 IsResolver: false, 233 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 234 switch field.Name { 235 case "height": 236 return ec.fieldContext_Size_height(ctx, field) 237 case "weight": 238 return ec.fieldContext_Size_weight(ctx, field) 239 } 240 return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) 241 }, 242 } 243 return fc, nil 244 } 245 246 func (ec *executionContext) _Cat_catBreed(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { 247 fc, err := ec.fieldContext_Cat_catBreed(ctx, field) 248 if err != nil { 249 return graphql.Null 250 } 251 ctx = graphql.WithFieldContext(ctx, fc) 252 defer func() { 253 if r := recover(); r != nil { 254 ec.Error(ctx, ec.Recover(ctx, r)) 255 ret = graphql.Null 256 } 257 }() 258 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 259 ctx = rctx // use context from middleware stack in children 260 return obj.CatBreed, nil 261 }) 262 263 if resTmp == nil { 264 if !graphql.HasFieldError(ctx, fc) { 265 ec.Errorf(ctx, "must not be null") 266 } 267 return graphql.Null 268 } 269 res := resTmp.(string) 270 fc.Result = res 271 return ec.marshalNString2string(ctx, field.Selections, res) 272 } 273 274 func (ec *executionContext) fieldContext_Cat_catBreed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 275 fc = &graphql.FieldContext{ 276 Object: "Cat", 277 Field: field, 278 IsMethod: false, 279 IsResolver: false, 280 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 281 return nil, errors.New("field of type String does not have child fields") 282 }, 283 } 284 return fc, nil 285 } 286 287 func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { 288 fc, err := ec.fieldContext_Circle_radius(ctx, field) 289 if err != nil { 290 return graphql.Null 291 } 292 ctx = graphql.WithFieldContext(ctx, fc) 293 defer func() { 294 if r := recover(); r != nil { 295 ec.Error(ctx, ec.Recover(ctx, r)) 296 ret = graphql.Null 297 } 298 }() 299 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 300 ctx = rctx // use context from middleware stack in children 301 return obj.Radius, nil 302 }) 303 304 if resTmp == nil { 305 return graphql.Null 306 } 307 res := resTmp.(float64) 308 fc.Result = res 309 return ec.marshalOFloat2float64(ctx, field.Selections, res) 310 } 311 312 func (ec *executionContext) fieldContext_Circle_radius(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 313 fc = &graphql.FieldContext{ 314 Object: "Circle", 315 Field: field, 316 IsMethod: false, 317 IsResolver: false, 318 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 319 return nil, errors.New("field of type Float does not have child fields") 320 }, 321 } 322 return fc, nil 323 } 324 325 func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { 326 fc, err := ec.fieldContext_Circle_area(ctx, field) 327 if err != nil { 328 return graphql.Null 329 } 330 ctx = graphql.WithFieldContext(ctx, fc) 331 defer func() { 332 if r := recover(); r != nil { 333 ec.Error(ctx, ec.Recover(ctx, r)) 334 ret = graphql.Null 335 } 336 }() 337 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 338 ctx = rctx // use context from middleware stack in children 339 return obj.Area(), nil 340 }) 341 342 if resTmp == nil { 343 return graphql.Null 344 } 345 res := resTmp.(float64) 346 fc.Result = res 347 return ec.marshalOFloat2float64(ctx, field.Selections, res) 348 } 349 350 func (ec *executionContext) fieldContext_Circle_area(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 351 fc = &graphql.FieldContext{ 352 Object: "Circle", 353 Field: field, 354 IsMethod: true, 355 IsResolver: false, 356 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 357 return nil, errors.New("field of type Float does not have child fields") 358 }, 359 } 360 return fc, nil 361 } 362 363 func (ec *executionContext) _Circle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { 364 fc, err := ec.fieldContext_Circle_coordinates(ctx, field) 365 if err != nil { 366 return graphql.Null 367 } 368 ctx = graphql.WithFieldContext(ctx, fc) 369 defer func() { 370 if r := recover(); r != nil { 371 ec.Error(ctx, ec.Recover(ctx, r)) 372 ret = graphql.Null 373 } 374 }() 375 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 376 ctx = rctx // use context from middleware stack in children 377 return obj.Coordinates, nil 378 }) 379 380 if resTmp == nil { 381 return graphql.Null 382 } 383 res := resTmp.(Coordinates) 384 fc.Result = res 385 return ec.marshalOCoordinates2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx, field.Selections, res) 386 } 387 388 func (ec *executionContext) fieldContext_Circle_coordinates(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 389 fc = &graphql.FieldContext{ 390 Object: "Circle", 391 Field: field, 392 IsMethod: false, 393 IsResolver: false, 394 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 395 switch field.Name { 396 case "x": 397 return ec.fieldContext_Coordinates_x(ctx, field) 398 case "y": 399 return ec.fieldContext_Coordinates_y(ctx, field) 400 } 401 return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) 402 }, 403 } 404 return fc, nil 405 } 406 407 func (ec *executionContext) _ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { 408 fc, err := ec.fieldContext_ConcreteNodeA_id(ctx, field) 409 if err != nil { 410 return graphql.Null 411 } 412 ctx = graphql.WithFieldContext(ctx, fc) 413 defer func() { 414 if r := recover(); r != nil { 415 ec.Error(ctx, ec.Recover(ctx, r)) 416 ret = graphql.Null 417 } 418 }() 419 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 420 ctx = rctx // use context from middleware stack in children 421 return obj.ID, nil 422 }) 423 424 if resTmp == nil { 425 if !graphql.HasFieldError(ctx, fc) { 426 ec.Errorf(ctx, "must not be null") 427 } 428 return graphql.Null 429 } 430 res := resTmp.(string) 431 fc.Result = res 432 return ec.marshalNID2string(ctx, field.Selections, res) 433 } 434 435 func (ec *executionContext) fieldContext_ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 436 fc = &graphql.FieldContext{ 437 Object: "ConcreteNodeA", 438 Field: field, 439 IsMethod: false, 440 IsResolver: false, 441 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 442 return nil, errors.New("field of type ID does not have child fields") 443 }, 444 } 445 return fc, nil 446 } 447 448 func (ec *executionContext) _ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { 449 fc, err := ec.fieldContext_ConcreteNodeA_child(ctx, field) 450 if err != nil { 451 return graphql.Null 452 } 453 ctx = graphql.WithFieldContext(ctx, fc) 454 defer func() { 455 if r := recover(); r != nil { 456 ec.Error(ctx, ec.Recover(ctx, r)) 457 ret = graphql.Null 458 } 459 }() 460 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 461 ctx = rctx // use context from middleware stack in children 462 return obj.Child() 463 }) 464 465 if resTmp == nil { 466 if !graphql.HasFieldError(ctx, fc) { 467 ec.Errorf(ctx, "must not be null") 468 } 469 return graphql.Null 470 } 471 res := resTmp.(Node) 472 fc.Result = res 473 return ec.marshalNNode2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res) 474 } 475 476 func (ec *executionContext) fieldContext_ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 477 fc = &graphql.FieldContext{ 478 Object: "ConcreteNodeA", 479 Field: field, 480 IsMethod: true, 481 IsResolver: false, 482 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 483 return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") 484 }, 485 } 486 return fc, nil 487 } 488 489 func (ec *executionContext) _ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { 490 fc, err := ec.fieldContext_ConcreteNodeA_name(ctx, field) 491 if err != nil { 492 return graphql.Null 493 } 494 ctx = graphql.WithFieldContext(ctx, fc) 495 defer func() { 496 if r := recover(); r != nil { 497 ec.Error(ctx, ec.Recover(ctx, r)) 498 ret = graphql.Null 499 } 500 }() 501 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 502 ctx = rctx // use context from middleware stack in children 503 return obj.Name, nil 504 }) 505 506 if resTmp == nil { 507 if !graphql.HasFieldError(ctx, fc) { 508 ec.Errorf(ctx, "must not be null") 509 } 510 return graphql.Null 511 } 512 res := resTmp.(string) 513 fc.Result = res 514 return ec.marshalNString2string(ctx, field.Selections, res) 515 } 516 517 func (ec *executionContext) fieldContext_ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 518 fc = &graphql.FieldContext{ 519 Object: "ConcreteNodeA", 520 Field: field, 521 IsMethod: false, 522 IsResolver: false, 523 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 524 return nil, errors.New("field of type String does not have child fields") 525 }, 526 } 527 return fc, nil 528 } 529 530 func (ec *executionContext) _ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { 531 fc, err := ec.fieldContext_ConcreteNodeInterface_id(ctx, field) 532 if err != nil { 533 return graphql.Null 534 } 535 ctx = graphql.WithFieldContext(ctx, fc) 536 defer func() { 537 if r := recover(); r != nil { 538 ec.Error(ctx, ec.Recover(ctx, r)) 539 ret = graphql.Null 540 } 541 }() 542 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 543 ctx = rctx // use context from middleware stack in children 544 return obj.ID(), nil 545 }) 546 547 if resTmp == nil { 548 if !graphql.HasFieldError(ctx, fc) { 549 ec.Errorf(ctx, "must not be null") 550 } 551 return graphql.Null 552 } 553 res := resTmp.(string) 554 fc.Result = res 555 return ec.marshalNID2string(ctx, field.Selections, res) 556 } 557 558 func (ec *executionContext) fieldContext_ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 559 fc = &graphql.FieldContext{ 560 Object: "ConcreteNodeInterface", 561 Field: field, 562 IsMethod: true, 563 IsResolver: false, 564 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 565 return nil, errors.New("field of type ID does not have child fields") 566 }, 567 } 568 return fc, nil 569 } 570 571 func (ec *executionContext) _ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { 572 fc, err := ec.fieldContext_ConcreteNodeInterface_child(ctx, field) 573 if err != nil { 574 return graphql.Null 575 } 576 ctx = graphql.WithFieldContext(ctx, fc) 577 defer func() { 578 if r := recover(); r != nil { 579 ec.Error(ctx, ec.Recover(ctx, r)) 580 ret = graphql.Null 581 } 582 }() 583 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 584 ctx = rctx // use context from middleware stack in children 585 return obj.Child() 586 }) 587 588 if resTmp == nil { 589 if !graphql.HasFieldError(ctx, fc) { 590 ec.Errorf(ctx, "must not be null") 591 } 592 return graphql.Null 593 } 594 res := resTmp.(Node) 595 fc.Result = res 596 return ec.marshalNNode2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res) 597 } 598 599 func (ec *executionContext) fieldContext_ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 600 fc = &graphql.FieldContext{ 601 Object: "ConcreteNodeInterface", 602 Field: field, 603 IsMethod: true, 604 IsResolver: false, 605 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 606 return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") 607 }, 608 } 609 return fc, nil 610 } 611 612 func (ec *executionContext) _Coordinates_x(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { 613 fc, err := ec.fieldContext_Coordinates_x(ctx, field) 614 if err != nil { 615 return graphql.Null 616 } 617 ctx = graphql.WithFieldContext(ctx, fc) 618 defer func() { 619 if r := recover(); r != nil { 620 ec.Error(ctx, ec.Recover(ctx, r)) 621 ret = graphql.Null 622 } 623 }() 624 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 625 ctx = rctx // use context from middleware stack in children 626 return obj.X, nil 627 }) 628 629 if resTmp == nil { 630 if !graphql.HasFieldError(ctx, fc) { 631 ec.Errorf(ctx, "must not be null") 632 } 633 return graphql.Null 634 } 635 res := resTmp.(float64) 636 fc.Result = res 637 return ec.marshalNFloat2float64(ctx, field.Selections, res) 638 } 639 640 func (ec *executionContext) fieldContext_Coordinates_x(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 641 fc = &graphql.FieldContext{ 642 Object: "Coordinates", 643 Field: field, 644 IsMethod: false, 645 IsResolver: false, 646 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 647 return nil, errors.New("field of type Float does not have child fields") 648 }, 649 } 650 return fc, nil 651 } 652 653 func (ec *executionContext) _Coordinates_y(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { 654 fc, err := ec.fieldContext_Coordinates_y(ctx, field) 655 if err != nil { 656 return graphql.Null 657 } 658 ctx = graphql.WithFieldContext(ctx, fc) 659 defer func() { 660 if r := recover(); r != nil { 661 ec.Error(ctx, ec.Recover(ctx, r)) 662 ret = graphql.Null 663 } 664 }() 665 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 666 ctx = rctx // use context from middleware stack in children 667 return obj.Y, nil 668 }) 669 670 if resTmp == nil { 671 if !graphql.HasFieldError(ctx, fc) { 672 ec.Errorf(ctx, "must not be null") 673 } 674 return graphql.Null 675 } 676 res := resTmp.(float64) 677 fc.Result = res 678 return ec.marshalNFloat2float64(ctx, field.Selections, res) 679 } 680 681 func (ec *executionContext) fieldContext_Coordinates_y(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 682 fc = &graphql.FieldContext{ 683 Object: "Coordinates", 684 Field: field, 685 IsMethod: false, 686 IsResolver: false, 687 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 688 return nil, errors.New("field of type Float does not have child fields") 689 }, 690 } 691 return fc, nil 692 } 693 694 func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { 695 fc, err := ec.fieldContext_Dog_species(ctx, field) 696 if err != nil { 697 return graphql.Null 698 } 699 ctx = graphql.WithFieldContext(ctx, fc) 700 defer func() { 701 if r := recover(); r != nil { 702 ec.Error(ctx, ec.Recover(ctx, r)) 703 ret = graphql.Null 704 } 705 }() 706 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 707 ctx = rctx // use context from middleware stack in children 708 return obj.Species, nil 709 }) 710 711 if resTmp == nil { 712 if !graphql.HasFieldError(ctx, fc) { 713 ec.Errorf(ctx, "must not be null") 714 } 715 return graphql.Null 716 } 717 res := resTmp.(string) 718 fc.Result = res 719 return ec.marshalNString2string(ctx, field.Selections, res) 720 } 721 722 func (ec *executionContext) fieldContext_Dog_species(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 723 fc = &graphql.FieldContext{ 724 Object: "Dog", 725 Field: field, 726 IsMethod: false, 727 IsResolver: false, 728 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 729 return nil, errors.New("field of type String does not have child fields") 730 }, 731 } 732 return fc, nil 733 } 734 735 func (ec *executionContext) _Dog_size(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { 736 fc, err := ec.fieldContext_Dog_size(ctx, field) 737 if err != nil { 738 return graphql.Null 739 } 740 ctx = graphql.WithFieldContext(ctx, fc) 741 defer func() { 742 if r := recover(); r != nil { 743 ec.Error(ctx, ec.Recover(ctx, r)) 744 ret = graphql.Null 745 } 746 }() 747 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 748 ctx = rctx // use context from middleware stack in children 749 return obj.Size, nil 750 }) 751 752 if resTmp == nil { 753 if !graphql.HasFieldError(ctx, fc) { 754 ec.Errorf(ctx, "must not be null") 755 } 756 return graphql.Null 757 } 758 res := resTmp.(*Size) 759 fc.Result = res 760 return ec.marshalNSize2ᚖgithubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx, field.Selections, res) 761 } 762 763 func (ec *executionContext) fieldContext_Dog_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 764 fc = &graphql.FieldContext{ 765 Object: "Dog", 766 Field: field, 767 IsMethod: false, 768 IsResolver: false, 769 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 770 switch field.Name { 771 case "height": 772 return ec.fieldContext_Size_height(ctx, field) 773 case "weight": 774 return ec.fieldContext_Size_weight(ctx, field) 775 } 776 return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) 777 }, 778 } 779 return fc, nil 780 } 781 782 func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { 783 fc, err := ec.fieldContext_Dog_dogBreed(ctx, field) 784 if err != nil { 785 return graphql.Null 786 } 787 ctx = graphql.WithFieldContext(ctx, fc) 788 defer func() { 789 if r := recover(); r != nil { 790 ec.Error(ctx, ec.Recover(ctx, r)) 791 ret = graphql.Null 792 } 793 }() 794 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 795 ctx = rctx // use context from middleware stack in children 796 return obj.DogBreed, nil 797 }) 798 799 if resTmp == nil { 800 if !graphql.HasFieldError(ctx, fc) { 801 ec.Errorf(ctx, "must not be null") 802 } 803 return graphql.Null 804 } 805 res := resTmp.(string) 806 fc.Result = res 807 return ec.marshalNString2string(ctx, field.Selections, res) 808 } 809 810 func (ec *executionContext) fieldContext_Dog_dogBreed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 811 fc = &graphql.FieldContext{ 812 Object: "Dog", 813 Field: field, 814 IsMethod: false, 815 IsResolver: false, 816 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 817 return nil, errors.New("field of type String does not have child fields") 818 }, 819 } 820 return fc, nil 821 } 822 823 func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { 824 fc, err := ec.fieldContext_Rectangle_length(ctx, field) 825 if err != nil { 826 return graphql.Null 827 } 828 ctx = graphql.WithFieldContext(ctx, fc) 829 defer func() { 830 if r := recover(); r != nil { 831 ec.Error(ctx, ec.Recover(ctx, r)) 832 ret = graphql.Null 833 } 834 }() 835 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 836 ctx = rctx // use context from middleware stack in children 837 return obj.Length, nil 838 }) 839 840 if resTmp == nil { 841 return graphql.Null 842 } 843 res := resTmp.(float64) 844 fc.Result = res 845 return ec.marshalOFloat2float64(ctx, field.Selections, res) 846 } 847 848 func (ec *executionContext) fieldContext_Rectangle_length(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 849 fc = &graphql.FieldContext{ 850 Object: "Rectangle", 851 Field: field, 852 IsMethod: false, 853 IsResolver: false, 854 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 855 return nil, errors.New("field of type Float does not have child fields") 856 }, 857 } 858 return fc, nil 859 } 860 861 func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { 862 fc, err := ec.fieldContext_Rectangle_width(ctx, field) 863 if err != nil { 864 return graphql.Null 865 } 866 ctx = graphql.WithFieldContext(ctx, fc) 867 defer func() { 868 if r := recover(); r != nil { 869 ec.Error(ctx, ec.Recover(ctx, r)) 870 ret = graphql.Null 871 } 872 }() 873 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 874 ctx = rctx // use context from middleware stack in children 875 return obj.Width, nil 876 }) 877 878 if resTmp == nil { 879 return graphql.Null 880 } 881 res := resTmp.(float64) 882 fc.Result = res 883 return ec.marshalOFloat2float64(ctx, field.Selections, res) 884 } 885 886 func (ec *executionContext) fieldContext_Rectangle_width(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 887 fc = &graphql.FieldContext{ 888 Object: "Rectangle", 889 Field: field, 890 IsMethod: false, 891 IsResolver: false, 892 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 893 return nil, errors.New("field of type Float does not have child fields") 894 }, 895 } 896 return fc, nil 897 } 898 899 func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { 900 fc, err := ec.fieldContext_Rectangle_area(ctx, field) 901 if err != nil { 902 return graphql.Null 903 } 904 ctx = graphql.WithFieldContext(ctx, fc) 905 defer func() { 906 if r := recover(); r != nil { 907 ec.Error(ctx, ec.Recover(ctx, r)) 908 ret = graphql.Null 909 } 910 }() 911 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 912 ctx = rctx // use context from middleware stack in children 913 return obj.Area(), nil 914 }) 915 916 if resTmp == nil { 917 return graphql.Null 918 } 919 res := resTmp.(float64) 920 fc.Result = res 921 return ec.marshalOFloat2float64(ctx, field.Selections, res) 922 } 923 924 func (ec *executionContext) fieldContext_Rectangle_area(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 925 fc = &graphql.FieldContext{ 926 Object: "Rectangle", 927 Field: field, 928 IsMethod: true, 929 IsResolver: false, 930 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 931 return nil, errors.New("field of type Float does not have child fields") 932 }, 933 } 934 return fc, nil 935 } 936 937 func (ec *executionContext) _Rectangle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { 938 fc, err := ec.fieldContext_Rectangle_coordinates(ctx, field) 939 if err != nil { 940 return graphql.Null 941 } 942 ctx = graphql.WithFieldContext(ctx, fc) 943 defer func() { 944 if r := recover(); r != nil { 945 ec.Error(ctx, ec.Recover(ctx, r)) 946 ret = graphql.Null 947 } 948 }() 949 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 950 ctx = rctx // use context from middleware stack in children 951 return obj.Coordinates, nil 952 }) 953 954 if resTmp == nil { 955 return graphql.Null 956 } 957 res := resTmp.(Coordinates) 958 fc.Result = res 959 return ec.marshalOCoordinates2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx, field.Selections, res) 960 } 961 962 func (ec *executionContext) fieldContext_Rectangle_coordinates(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 963 fc = &graphql.FieldContext{ 964 Object: "Rectangle", 965 Field: field, 966 IsMethod: false, 967 IsResolver: false, 968 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 969 switch field.Name { 970 case "x": 971 return ec.fieldContext_Coordinates_x(ctx, field) 972 case "y": 973 return ec.fieldContext_Coordinates_y(ctx, field) 974 } 975 return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) 976 }, 977 } 978 return fc, nil 979 } 980 981 func (ec *executionContext) _Size_height(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { 982 fc, err := ec.fieldContext_Size_height(ctx, field) 983 if err != nil { 984 return graphql.Null 985 } 986 ctx = graphql.WithFieldContext(ctx, fc) 987 defer func() { 988 if r := recover(); r != nil { 989 ec.Error(ctx, ec.Recover(ctx, r)) 990 ret = graphql.Null 991 } 992 }() 993 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 994 ctx = rctx // use context from middleware stack in children 995 return obj.Height, nil 996 }) 997 998 if resTmp == nil { 999 if !graphql.HasFieldError(ctx, fc) { 1000 ec.Errorf(ctx, "must not be null") 1001 } 1002 return graphql.Null 1003 } 1004 res := resTmp.(int) 1005 fc.Result = res 1006 return ec.marshalNInt2int(ctx, field.Selections, res) 1007 } 1008 1009 func (ec *executionContext) fieldContext_Size_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1010 fc = &graphql.FieldContext{ 1011 Object: "Size", 1012 Field: field, 1013 IsMethod: false, 1014 IsResolver: false, 1015 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1016 return nil, errors.New("field of type Int does not have child fields") 1017 }, 1018 } 1019 return fc, nil 1020 } 1021 1022 func (ec *executionContext) _Size_weight(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { 1023 fc, err := ec.fieldContext_Size_weight(ctx, field) 1024 if err != nil { 1025 return graphql.Null 1026 } 1027 ctx = graphql.WithFieldContext(ctx, fc) 1028 defer func() { 1029 if r := recover(); r != nil { 1030 ec.Error(ctx, ec.Recover(ctx, r)) 1031 ret = graphql.Null 1032 } 1033 }() 1034 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 1035 ctx = rctx // use context from middleware stack in children 1036 return obj.Weight, nil 1037 }) 1038 1039 if resTmp == nil { 1040 if !graphql.HasFieldError(ctx, fc) { 1041 ec.Errorf(ctx, "must not be null") 1042 } 1043 return graphql.Null 1044 } 1045 res := resTmp.(int) 1046 fc.Result = res 1047 return ec.marshalNInt2int(ctx, field.Selections, res) 1048 } 1049 1050 func (ec *executionContext) fieldContext_Size_weight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { 1051 fc = &graphql.FieldContext{ 1052 Object: "Size", 1053 Field: field, 1054 IsMethod: false, 1055 IsResolver: false, 1056 Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { 1057 return nil, errors.New("field of type Int does not have child fields") 1058 }, 1059 } 1060 return fc, nil 1061 } 1062 1063 // endregion **************************** field.gotpl ***************************** 1064 1065 // region **************************** input.gotpl ***************************** 1066 1067 // endregion **************************** input.gotpl ***************************** 1068 1069 // region ************************** interface.gotpl *************************** 1070 1071 func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, obj Animal) graphql.Marshaler { 1072 switch obj := (obj).(type) { 1073 case nil: 1074 return graphql.Null 1075 case Dog: 1076 return ec._Dog(ctx, sel, &obj) 1077 case *Dog: 1078 if obj == nil { 1079 return graphql.Null 1080 } 1081 return ec._Dog(ctx, sel, obj) 1082 case Cat: 1083 return ec._Cat(ctx, sel, &obj) 1084 case *Cat: 1085 if obj == nil { 1086 return graphql.Null 1087 } 1088 return ec._Cat(ctx, sel, obj) 1089 default: 1090 panic(fmt.Errorf("unexpected type %T", obj)) 1091 } 1092 } 1093 1094 func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj Node) graphql.Marshaler { 1095 switch obj := (obj).(type) { 1096 case nil: 1097 return graphql.Null 1098 case *ConcreteNodeA: 1099 if obj == nil { 1100 return graphql.Null 1101 } 1102 return ec._ConcreteNodeA(ctx, sel, obj) 1103 case ConcreteNodeInterface: 1104 if obj == nil { 1105 return graphql.Null 1106 } 1107 return ec._ConcreteNodeInterface(ctx, sel, obj) 1108 default: 1109 panic(fmt.Errorf("unexpected type %T", obj)) 1110 } 1111 } 1112 1113 func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, obj Shape) graphql.Marshaler { 1114 switch obj := (obj).(type) { 1115 case nil: 1116 return graphql.Null 1117 case *Circle: 1118 if obj == nil { 1119 return graphql.Null 1120 } 1121 return ec._Circle(ctx, sel, obj) 1122 case *Rectangle: 1123 if obj == nil { 1124 return graphql.Null 1125 } 1126 return ec._Rectangle(ctx, sel, obj) 1127 default: 1128 panic(fmt.Errorf("unexpected type %T", obj)) 1129 } 1130 } 1131 1132 func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSet, obj ShapeUnion) graphql.Marshaler { 1133 switch obj := (obj).(type) { 1134 case nil: 1135 return graphql.Null 1136 case *Circle: 1137 if obj == nil { 1138 return graphql.Null 1139 } 1140 return ec._Circle(ctx, sel, obj) 1141 case *Rectangle: 1142 if obj == nil { 1143 return graphql.Null 1144 } 1145 return ec._Rectangle(ctx, sel, obj) 1146 default: 1147 panic(fmt.Errorf("unexpected type %T", obj)) 1148 } 1149 } 1150 1151 // endregion ************************** interface.gotpl *************************** 1152 1153 // region **************************** object.gotpl **************************** 1154 1155 var backedByInterfaceImplementors = []string{"BackedByInterface"} 1156 1157 func (ec *executionContext) _BackedByInterface(ctx context.Context, sel ast.SelectionSet, obj BackedByInterface) graphql.Marshaler { 1158 fields := graphql.CollectFields(ec.OperationContext, sel, backedByInterfaceImplementors) 1159 1160 out := graphql.NewFieldSet(fields) 1161 deferred := make(map[string]*graphql.FieldSet) 1162 for i, field := range fields { 1163 switch field.Name { 1164 case "__typename": 1165 out.Values[i] = graphql.MarshalString("BackedByInterface") 1166 case "id": 1167 field := field 1168 1169 innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { 1170 defer func() { 1171 if r := recover(); r != nil { 1172 ec.Error(ctx, ec.Recover(ctx, r)) 1173 } 1174 }() 1175 res = ec._BackedByInterface_id(ctx, field, obj) 1176 if res == graphql.Null { 1177 atomic.AddUint32(&fs.Invalids, 1) 1178 } 1179 return res 1180 } 1181 1182 if field.Deferrable != nil { 1183 dfs, ok := deferred[field.Deferrable.Label] 1184 di := 0 1185 if ok { 1186 dfs.AddField(field) 1187 di = len(dfs.Values) - 1 1188 } else { 1189 dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) 1190 deferred[field.Deferrable.Label] = dfs 1191 } 1192 dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { 1193 return innerFunc(ctx, dfs) 1194 }) 1195 1196 // don't run the out.Concurrently() call below 1197 out.Values[i] = graphql.Null 1198 continue 1199 } 1200 1201 out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) 1202 case "thisShouldBind": 1203 out.Values[i] = ec._BackedByInterface_thisShouldBind(ctx, field, obj) 1204 if out.Values[i] == graphql.Null { 1205 atomic.AddUint32(&out.Invalids, 1) 1206 } 1207 case "thisShouldBindWithError": 1208 out.Values[i] = ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj) 1209 if out.Values[i] == graphql.Null { 1210 atomic.AddUint32(&out.Invalids, 1) 1211 } 1212 default: 1213 panic("unknown field " + strconv.Quote(field.Name)) 1214 } 1215 } 1216 out.Dispatch(ctx) 1217 if out.Invalids > 0 { 1218 return graphql.Null 1219 } 1220 1221 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1222 1223 for label, dfs := range deferred { 1224 ec.processDeferredGroup(graphql.DeferredGroup{ 1225 Label: label, 1226 Path: graphql.GetPath(ctx), 1227 FieldSet: dfs, 1228 Context: ctx, 1229 }) 1230 } 1231 1232 return out 1233 } 1234 1235 var catImplementors = []string{"Cat", "Animal"} 1236 1237 func (ec *executionContext) _Cat(ctx context.Context, sel ast.SelectionSet, obj *Cat) graphql.Marshaler { 1238 fields := graphql.CollectFields(ec.OperationContext, sel, catImplementors) 1239 1240 out := graphql.NewFieldSet(fields) 1241 deferred := make(map[string]*graphql.FieldSet) 1242 for i, field := range fields { 1243 switch field.Name { 1244 case "__typename": 1245 out.Values[i] = graphql.MarshalString("Cat") 1246 case "species": 1247 out.Values[i] = ec._Cat_species(ctx, field, obj) 1248 if out.Values[i] == graphql.Null { 1249 out.Invalids++ 1250 } 1251 case "size": 1252 out.Values[i] = ec._Cat_size(ctx, field, obj) 1253 if out.Values[i] == graphql.Null { 1254 out.Invalids++ 1255 } 1256 case "catBreed": 1257 out.Values[i] = ec._Cat_catBreed(ctx, field, obj) 1258 if out.Values[i] == graphql.Null { 1259 out.Invalids++ 1260 } 1261 default: 1262 panic("unknown field " + strconv.Quote(field.Name)) 1263 } 1264 } 1265 out.Dispatch(ctx) 1266 if out.Invalids > 0 { 1267 return graphql.Null 1268 } 1269 1270 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1271 1272 for label, dfs := range deferred { 1273 ec.processDeferredGroup(graphql.DeferredGroup{ 1274 Label: label, 1275 Path: graphql.GetPath(ctx), 1276 FieldSet: dfs, 1277 Context: ctx, 1278 }) 1279 } 1280 1281 return out 1282 } 1283 1284 var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} 1285 1286 func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { 1287 fields := graphql.CollectFields(ec.OperationContext, sel, circleImplementors) 1288 1289 out := graphql.NewFieldSet(fields) 1290 deferred := make(map[string]*graphql.FieldSet) 1291 for i, field := range fields { 1292 switch field.Name { 1293 case "__typename": 1294 out.Values[i] = graphql.MarshalString("Circle") 1295 case "radius": 1296 out.Values[i] = ec._Circle_radius(ctx, field, obj) 1297 case "area": 1298 out.Values[i] = ec._Circle_area(ctx, field, obj) 1299 case "coordinates": 1300 out.Values[i] = ec._Circle_coordinates(ctx, field, obj) 1301 default: 1302 panic("unknown field " + strconv.Quote(field.Name)) 1303 } 1304 } 1305 out.Dispatch(ctx) 1306 if out.Invalids > 0 { 1307 return graphql.Null 1308 } 1309 1310 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1311 1312 for label, dfs := range deferred { 1313 ec.processDeferredGroup(graphql.DeferredGroup{ 1314 Label: label, 1315 Path: graphql.GetPath(ctx), 1316 FieldSet: dfs, 1317 Context: ctx, 1318 }) 1319 } 1320 1321 return out 1322 } 1323 1324 var concreteNodeAImplementors = []string{"ConcreteNodeA", "Node"} 1325 1326 func (ec *executionContext) _ConcreteNodeA(ctx context.Context, sel ast.SelectionSet, obj *ConcreteNodeA) graphql.Marshaler { 1327 fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeAImplementors) 1328 1329 out := graphql.NewFieldSet(fields) 1330 deferred := make(map[string]*graphql.FieldSet) 1331 for i, field := range fields { 1332 switch field.Name { 1333 case "__typename": 1334 out.Values[i] = graphql.MarshalString("ConcreteNodeA") 1335 case "id": 1336 out.Values[i] = ec._ConcreteNodeA_id(ctx, field, obj) 1337 if out.Values[i] == graphql.Null { 1338 out.Invalids++ 1339 } 1340 case "child": 1341 out.Values[i] = ec._ConcreteNodeA_child(ctx, field, obj) 1342 if out.Values[i] == graphql.Null { 1343 out.Invalids++ 1344 } 1345 case "name": 1346 out.Values[i] = ec._ConcreteNodeA_name(ctx, field, obj) 1347 if out.Values[i] == graphql.Null { 1348 out.Invalids++ 1349 } 1350 default: 1351 panic("unknown field " + strconv.Quote(field.Name)) 1352 } 1353 } 1354 out.Dispatch(ctx) 1355 if out.Invalids > 0 { 1356 return graphql.Null 1357 } 1358 1359 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1360 1361 for label, dfs := range deferred { 1362 ec.processDeferredGroup(graphql.DeferredGroup{ 1363 Label: label, 1364 Path: graphql.GetPath(ctx), 1365 FieldSet: dfs, 1366 Context: ctx, 1367 }) 1368 } 1369 1370 return out 1371 } 1372 1373 var concreteNodeInterfaceImplementors = []string{"ConcreteNodeInterface", "Node"} 1374 1375 func (ec *executionContext) _ConcreteNodeInterface(ctx context.Context, sel ast.SelectionSet, obj ConcreteNodeInterface) graphql.Marshaler { 1376 fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeInterfaceImplementors) 1377 1378 out := graphql.NewFieldSet(fields) 1379 deferred := make(map[string]*graphql.FieldSet) 1380 for i, field := range fields { 1381 switch field.Name { 1382 case "__typename": 1383 out.Values[i] = graphql.MarshalString("ConcreteNodeInterface") 1384 case "id": 1385 out.Values[i] = ec._ConcreteNodeInterface_id(ctx, field, obj) 1386 if out.Values[i] == graphql.Null { 1387 out.Invalids++ 1388 } 1389 case "child": 1390 out.Values[i] = ec._ConcreteNodeInterface_child(ctx, field, obj) 1391 if out.Values[i] == graphql.Null { 1392 out.Invalids++ 1393 } 1394 default: 1395 panic("unknown field " + strconv.Quote(field.Name)) 1396 } 1397 } 1398 out.Dispatch(ctx) 1399 if out.Invalids > 0 { 1400 return graphql.Null 1401 } 1402 1403 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1404 1405 for label, dfs := range deferred { 1406 ec.processDeferredGroup(graphql.DeferredGroup{ 1407 Label: label, 1408 Path: graphql.GetPath(ctx), 1409 FieldSet: dfs, 1410 Context: ctx, 1411 }) 1412 } 1413 1414 return out 1415 } 1416 1417 var coordinatesImplementors = []string{"Coordinates"} 1418 1419 func (ec *executionContext) _Coordinates(ctx context.Context, sel ast.SelectionSet, obj *Coordinates) graphql.Marshaler { 1420 fields := graphql.CollectFields(ec.OperationContext, sel, coordinatesImplementors) 1421 1422 out := graphql.NewFieldSet(fields) 1423 deferred := make(map[string]*graphql.FieldSet) 1424 for i, field := range fields { 1425 switch field.Name { 1426 case "__typename": 1427 out.Values[i] = graphql.MarshalString("Coordinates") 1428 case "x": 1429 out.Values[i] = ec._Coordinates_x(ctx, field, obj) 1430 if out.Values[i] == graphql.Null { 1431 out.Invalids++ 1432 } 1433 case "y": 1434 out.Values[i] = ec._Coordinates_y(ctx, field, obj) 1435 if out.Values[i] == graphql.Null { 1436 out.Invalids++ 1437 } 1438 default: 1439 panic("unknown field " + strconv.Quote(field.Name)) 1440 } 1441 } 1442 out.Dispatch(ctx) 1443 if out.Invalids > 0 { 1444 return graphql.Null 1445 } 1446 1447 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1448 1449 for label, dfs := range deferred { 1450 ec.processDeferredGroup(graphql.DeferredGroup{ 1451 Label: label, 1452 Path: graphql.GetPath(ctx), 1453 FieldSet: dfs, 1454 Context: ctx, 1455 }) 1456 } 1457 1458 return out 1459 } 1460 1461 var dogImplementors = []string{"Dog", "Animal"} 1462 1463 func (ec *executionContext) _Dog(ctx context.Context, sel ast.SelectionSet, obj *Dog) graphql.Marshaler { 1464 fields := graphql.CollectFields(ec.OperationContext, sel, dogImplementors) 1465 1466 out := graphql.NewFieldSet(fields) 1467 deferred := make(map[string]*graphql.FieldSet) 1468 for i, field := range fields { 1469 switch field.Name { 1470 case "__typename": 1471 out.Values[i] = graphql.MarshalString("Dog") 1472 case "species": 1473 out.Values[i] = ec._Dog_species(ctx, field, obj) 1474 if out.Values[i] == graphql.Null { 1475 out.Invalids++ 1476 } 1477 case "size": 1478 out.Values[i] = ec._Dog_size(ctx, field, obj) 1479 if out.Values[i] == graphql.Null { 1480 out.Invalids++ 1481 } 1482 case "dogBreed": 1483 out.Values[i] = ec._Dog_dogBreed(ctx, field, obj) 1484 if out.Values[i] == graphql.Null { 1485 out.Invalids++ 1486 } 1487 default: 1488 panic("unknown field " + strconv.Quote(field.Name)) 1489 } 1490 } 1491 out.Dispatch(ctx) 1492 if out.Invalids > 0 { 1493 return graphql.Null 1494 } 1495 1496 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1497 1498 for label, dfs := range deferred { 1499 ec.processDeferredGroup(graphql.DeferredGroup{ 1500 Label: label, 1501 Path: graphql.GetPath(ctx), 1502 FieldSet: dfs, 1503 Context: ctx, 1504 }) 1505 } 1506 1507 return out 1508 } 1509 1510 var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"} 1511 1512 func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { 1513 fields := graphql.CollectFields(ec.OperationContext, sel, rectangleImplementors) 1514 1515 out := graphql.NewFieldSet(fields) 1516 deferred := make(map[string]*graphql.FieldSet) 1517 for i, field := range fields { 1518 switch field.Name { 1519 case "__typename": 1520 out.Values[i] = graphql.MarshalString("Rectangle") 1521 case "length": 1522 out.Values[i] = ec._Rectangle_length(ctx, field, obj) 1523 case "width": 1524 out.Values[i] = ec._Rectangle_width(ctx, field, obj) 1525 case "area": 1526 out.Values[i] = ec._Rectangle_area(ctx, field, obj) 1527 case "coordinates": 1528 out.Values[i] = ec._Rectangle_coordinates(ctx, field, obj) 1529 default: 1530 panic("unknown field " + strconv.Quote(field.Name)) 1531 } 1532 } 1533 out.Dispatch(ctx) 1534 if out.Invalids > 0 { 1535 return graphql.Null 1536 } 1537 1538 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1539 1540 for label, dfs := range deferred { 1541 ec.processDeferredGroup(graphql.DeferredGroup{ 1542 Label: label, 1543 Path: graphql.GetPath(ctx), 1544 FieldSet: dfs, 1545 Context: ctx, 1546 }) 1547 } 1548 1549 return out 1550 } 1551 1552 var sizeImplementors = []string{"Size"} 1553 1554 func (ec *executionContext) _Size(ctx context.Context, sel ast.SelectionSet, obj *Size) graphql.Marshaler { 1555 fields := graphql.CollectFields(ec.OperationContext, sel, sizeImplementors) 1556 1557 out := graphql.NewFieldSet(fields) 1558 deferred := make(map[string]*graphql.FieldSet) 1559 for i, field := range fields { 1560 switch field.Name { 1561 case "__typename": 1562 out.Values[i] = graphql.MarshalString("Size") 1563 case "height": 1564 out.Values[i] = ec._Size_height(ctx, field, obj) 1565 if out.Values[i] == graphql.Null { 1566 out.Invalids++ 1567 } 1568 case "weight": 1569 out.Values[i] = ec._Size_weight(ctx, field, obj) 1570 if out.Values[i] == graphql.Null { 1571 out.Invalids++ 1572 } 1573 default: 1574 panic("unknown field " + strconv.Quote(field.Name)) 1575 } 1576 } 1577 out.Dispatch(ctx) 1578 if out.Invalids > 0 { 1579 return graphql.Null 1580 } 1581 1582 atomic.AddInt32(&ec.deferred, int32(len(deferred))) 1583 1584 for label, dfs := range deferred { 1585 ec.processDeferredGroup(graphql.DeferredGroup{ 1586 Label: label, 1587 Path: graphql.GetPath(ctx), 1588 FieldSet: dfs, 1589 Context: ctx, 1590 }) 1591 } 1592 1593 return out 1594 } 1595 1596 // endregion **************************** object.gotpl **************************** 1597 1598 // region ***************************** type.gotpl ***************************** 1599 1600 func (ec *executionContext) marshalNNode2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler { 1601 if v == nil { 1602 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1603 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 1604 } 1605 return graphql.Null 1606 } 1607 return ec._Node(ctx, sel, v) 1608 } 1609 1610 func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler { 1611 if v == nil { 1612 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1613 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 1614 } 1615 return graphql.Null 1616 } 1617 return ec._ShapeUnion(ctx, sel, v) 1618 } 1619 1620 func (ec *executionContext) marshalNSize2ᚖgithubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx context.Context, sel ast.SelectionSet, v *Size) graphql.Marshaler { 1621 if v == nil { 1622 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1623 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 1624 } 1625 return graphql.Null 1626 } 1627 return ec._Size(ctx, sel, v) 1628 } 1629 1630 func (ec *executionContext) marshalOAnimal2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAnimal(ctx context.Context, sel ast.SelectionSet, v Animal) graphql.Marshaler { 1631 if v == nil { 1632 return graphql.Null 1633 } 1634 return ec._Animal(ctx, sel, v) 1635 } 1636 1637 func (ec *executionContext) marshalOBackedByInterface2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐBackedByInterface(ctx context.Context, sel ast.SelectionSet, v BackedByInterface) graphql.Marshaler { 1638 if v == nil { 1639 return graphql.Null 1640 } 1641 return ec._BackedByInterface(ctx, sel, v) 1642 } 1643 1644 func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { 1645 if v == nil { 1646 return graphql.Null 1647 } 1648 return ec._Circle(ctx, sel, v) 1649 } 1650 1651 func (ec *executionContext) marshalOCoordinates2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler { 1652 return ec._Coordinates(ctx, sel, &v) 1653 } 1654 1655 func (ec *executionContext) marshalODog2ᚖgithubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDog(ctx context.Context, sel ast.SelectionSet, v *Dog) graphql.Marshaler { 1656 if v == nil { 1657 return graphql.Null 1658 } 1659 return ec._Dog(ctx, sel, v) 1660 } 1661 1662 func (ec *executionContext) marshalOShape2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { 1663 if v == nil { 1664 return graphql.Null 1665 } 1666 return ec._Shape(ctx, sel, v) 1667 } 1668 1669 func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { 1670 if v == nil { 1671 return graphql.Null 1672 } 1673 ret := make(graphql.Array, len(v)) 1674 var wg sync.WaitGroup 1675 isLen1 := len(v) == 1 1676 if !isLen1 { 1677 wg.Add(len(v)) 1678 } 1679 for i := range v { 1680 i := i 1681 fc := &graphql.FieldContext{ 1682 Index: &i, 1683 Result: &v[i], 1684 } 1685 ctx := graphql.WithFieldContext(ctx, fc) 1686 f := func(i int) { 1687 defer func() { 1688 if r := recover(); r != nil { 1689 ec.Error(ctx, ec.Recover(ctx, r)) 1690 ret = nil 1691 } 1692 }() 1693 if !isLen1 { 1694 defer wg.Done() 1695 } 1696 ret[i] = ec.marshalOShape2githubᚗcomᚋgenevaᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, sel, v[i]) 1697 } 1698 if isLen1 { 1699 f(i) 1700 } else { 1701 go f(i) 1702 } 1703 1704 } 1705 wg.Wait() 1706 1707 return ret 1708 } 1709 1710 // endregion ***************************** type.gotpl *****************************