github.com/spread-ai/gqlgen@v0.0.0-20221124102857-a6c8ef538a1d/codegen/testserver/followschema/interfaces.generated.go (about) 1 // Code generated by github.com/spread-ai/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/spread-ai/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ᚋ99designsᚋ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ᚋ99designsᚋ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ᚋ99designsᚋ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ᚋ99designsᚋ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ᚋ99designsᚋ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ᚋ99designsᚋ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 out := graphql.NewFieldSet(fields) 1160 var invalids uint32 1161 for i, field := range fields { 1162 switch field.Name { 1163 case "__typename": 1164 out.Values[i] = graphql.MarshalString("BackedByInterface") 1165 case "id": 1166 field := field 1167 1168 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 1169 defer func() { 1170 if r := recover(); r != nil { 1171 ec.Error(ctx, ec.Recover(ctx, r)) 1172 } 1173 }() 1174 res = ec._BackedByInterface_id(ctx, field, obj) 1175 if res == graphql.Null { 1176 atomic.AddUint32(&invalids, 1) 1177 } 1178 return res 1179 } 1180 1181 out.Concurrently(i, func() graphql.Marshaler { 1182 return innerFunc(ctx) 1183 1184 }) 1185 case "thisShouldBind": 1186 1187 out.Values[i] = ec._BackedByInterface_thisShouldBind(ctx, field, obj) 1188 1189 if out.Values[i] == graphql.Null { 1190 atomic.AddUint32(&invalids, 1) 1191 } 1192 case "thisShouldBindWithError": 1193 1194 out.Values[i] = ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj) 1195 1196 if out.Values[i] == graphql.Null { 1197 atomic.AddUint32(&invalids, 1) 1198 } 1199 default: 1200 panic("unknown field " + strconv.Quote(field.Name)) 1201 } 1202 } 1203 out.Dispatch() 1204 if invalids > 0 { 1205 return graphql.Null 1206 } 1207 return out 1208 } 1209 1210 var catImplementors = []string{"Cat", "Animal"} 1211 1212 func (ec *executionContext) _Cat(ctx context.Context, sel ast.SelectionSet, obj *Cat) graphql.Marshaler { 1213 fields := graphql.CollectFields(ec.OperationContext, sel, catImplementors) 1214 out := graphql.NewFieldSet(fields) 1215 var invalids uint32 1216 for i, field := range fields { 1217 switch field.Name { 1218 case "__typename": 1219 out.Values[i] = graphql.MarshalString("Cat") 1220 case "species": 1221 1222 out.Values[i] = ec._Cat_species(ctx, field, obj) 1223 1224 if out.Values[i] == graphql.Null { 1225 invalids++ 1226 } 1227 case "size": 1228 1229 out.Values[i] = ec._Cat_size(ctx, field, obj) 1230 1231 if out.Values[i] == graphql.Null { 1232 invalids++ 1233 } 1234 case "catBreed": 1235 1236 out.Values[i] = ec._Cat_catBreed(ctx, field, obj) 1237 1238 if out.Values[i] == graphql.Null { 1239 invalids++ 1240 } 1241 default: 1242 panic("unknown field " + strconv.Quote(field.Name)) 1243 } 1244 } 1245 out.Dispatch() 1246 if invalids > 0 { 1247 return graphql.Null 1248 } 1249 return out 1250 } 1251 1252 var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} 1253 1254 func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { 1255 fields := graphql.CollectFields(ec.OperationContext, sel, circleImplementors) 1256 out := graphql.NewFieldSet(fields) 1257 var invalids uint32 1258 for i, field := range fields { 1259 switch field.Name { 1260 case "__typename": 1261 out.Values[i] = graphql.MarshalString("Circle") 1262 case "radius": 1263 1264 out.Values[i] = ec._Circle_radius(ctx, field, obj) 1265 1266 case "area": 1267 1268 out.Values[i] = ec._Circle_area(ctx, field, obj) 1269 1270 case "coordinates": 1271 1272 out.Values[i] = ec._Circle_coordinates(ctx, field, obj) 1273 1274 default: 1275 panic("unknown field " + strconv.Quote(field.Name)) 1276 } 1277 } 1278 out.Dispatch() 1279 if invalids > 0 { 1280 return graphql.Null 1281 } 1282 return out 1283 } 1284 1285 var concreteNodeAImplementors = []string{"ConcreteNodeA", "Node"} 1286 1287 func (ec *executionContext) _ConcreteNodeA(ctx context.Context, sel ast.SelectionSet, obj *ConcreteNodeA) graphql.Marshaler { 1288 fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeAImplementors) 1289 out := graphql.NewFieldSet(fields) 1290 var invalids uint32 1291 for i, field := range fields { 1292 switch field.Name { 1293 case "__typename": 1294 out.Values[i] = graphql.MarshalString("ConcreteNodeA") 1295 case "id": 1296 1297 out.Values[i] = ec._ConcreteNodeA_id(ctx, field, obj) 1298 1299 if out.Values[i] == graphql.Null { 1300 invalids++ 1301 } 1302 case "child": 1303 1304 out.Values[i] = ec._ConcreteNodeA_child(ctx, field, obj) 1305 1306 if out.Values[i] == graphql.Null { 1307 invalids++ 1308 } 1309 case "name": 1310 1311 out.Values[i] = ec._ConcreteNodeA_name(ctx, field, obj) 1312 1313 if out.Values[i] == graphql.Null { 1314 invalids++ 1315 } 1316 default: 1317 panic("unknown field " + strconv.Quote(field.Name)) 1318 } 1319 } 1320 out.Dispatch() 1321 if invalids > 0 { 1322 return graphql.Null 1323 } 1324 return out 1325 } 1326 1327 var concreteNodeInterfaceImplementors = []string{"ConcreteNodeInterface", "Node"} 1328 1329 func (ec *executionContext) _ConcreteNodeInterface(ctx context.Context, sel ast.SelectionSet, obj ConcreteNodeInterface) graphql.Marshaler { 1330 fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeInterfaceImplementors) 1331 out := graphql.NewFieldSet(fields) 1332 var invalids uint32 1333 for i, field := range fields { 1334 switch field.Name { 1335 case "__typename": 1336 out.Values[i] = graphql.MarshalString("ConcreteNodeInterface") 1337 case "id": 1338 1339 out.Values[i] = ec._ConcreteNodeInterface_id(ctx, field, obj) 1340 1341 if out.Values[i] == graphql.Null { 1342 invalids++ 1343 } 1344 case "child": 1345 1346 out.Values[i] = ec._ConcreteNodeInterface_child(ctx, field, obj) 1347 1348 if out.Values[i] == graphql.Null { 1349 invalids++ 1350 } 1351 default: 1352 panic("unknown field " + strconv.Quote(field.Name)) 1353 } 1354 } 1355 out.Dispatch() 1356 if invalids > 0 { 1357 return graphql.Null 1358 } 1359 return out 1360 } 1361 1362 var coordinatesImplementors = []string{"Coordinates"} 1363 1364 func (ec *executionContext) _Coordinates(ctx context.Context, sel ast.SelectionSet, obj *Coordinates) graphql.Marshaler { 1365 fields := graphql.CollectFields(ec.OperationContext, sel, coordinatesImplementors) 1366 out := graphql.NewFieldSet(fields) 1367 var invalids uint32 1368 for i, field := range fields { 1369 switch field.Name { 1370 case "__typename": 1371 out.Values[i] = graphql.MarshalString("Coordinates") 1372 case "x": 1373 1374 out.Values[i] = ec._Coordinates_x(ctx, field, obj) 1375 1376 if out.Values[i] == graphql.Null { 1377 invalids++ 1378 } 1379 case "y": 1380 1381 out.Values[i] = ec._Coordinates_y(ctx, field, obj) 1382 1383 if out.Values[i] == graphql.Null { 1384 invalids++ 1385 } 1386 default: 1387 panic("unknown field " + strconv.Quote(field.Name)) 1388 } 1389 } 1390 out.Dispatch() 1391 if invalids > 0 { 1392 return graphql.Null 1393 } 1394 return out 1395 } 1396 1397 var dogImplementors = []string{"Dog", "Animal"} 1398 1399 func (ec *executionContext) _Dog(ctx context.Context, sel ast.SelectionSet, obj *Dog) graphql.Marshaler { 1400 fields := graphql.CollectFields(ec.OperationContext, sel, dogImplementors) 1401 out := graphql.NewFieldSet(fields) 1402 var invalids uint32 1403 for i, field := range fields { 1404 switch field.Name { 1405 case "__typename": 1406 out.Values[i] = graphql.MarshalString("Dog") 1407 case "species": 1408 1409 out.Values[i] = ec._Dog_species(ctx, field, obj) 1410 1411 if out.Values[i] == graphql.Null { 1412 invalids++ 1413 } 1414 case "size": 1415 1416 out.Values[i] = ec._Dog_size(ctx, field, obj) 1417 1418 if out.Values[i] == graphql.Null { 1419 invalids++ 1420 } 1421 case "dogBreed": 1422 1423 out.Values[i] = ec._Dog_dogBreed(ctx, field, obj) 1424 1425 if out.Values[i] == graphql.Null { 1426 invalids++ 1427 } 1428 default: 1429 panic("unknown field " + strconv.Quote(field.Name)) 1430 } 1431 } 1432 out.Dispatch() 1433 if invalids > 0 { 1434 return graphql.Null 1435 } 1436 return out 1437 } 1438 1439 var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"} 1440 1441 func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { 1442 fields := graphql.CollectFields(ec.OperationContext, sel, rectangleImplementors) 1443 out := graphql.NewFieldSet(fields) 1444 var invalids uint32 1445 for i, field := range fields { 1446 switch field.Name { 1447 case "__typename": 1448 out.Values[i] = graphql.MarshalString("Rectangle") 1449 case "length": 1450 1451 out.Values[i] = ec._Rectangle_length(ctx, field, obj) 1452 1453 case "width": 1454 1455 out.Values[i] = ec._Rectangle_width(ctx, field, obj) 1456 1457 case "area": 1458 1459 out.Values[i] = ec._Rectangle_area(ctx, field, obj) 1460 1461 case "coordinates": 1462 1463 out.Values[i] = ec._Rectangle_coordinates(ctx, field, obj) 1464 1465 default: 1466 panic("unknown field " + strconv.Quote(field.Name)) 1467 } 1468 } 1469 out.Dispatch() 1470 if invalids > 0 { 1471 return graphql.Null 1472 } 1473 return out 1474 } 1475 1476 var sizeImplementors = []string{"Size"} 1477 1478 func (ec *executionContext) _Size(ctx context.Context, sel ast.SelectionSet, obj *Size) graphql.Marshaler { 1479 fields := graphql.CollectFields(ec.OperationContext, sel, sizeImplementors) 1480 out := graphql.NewFieldSet(fields) 1481 var invalids uint32 1482 for i, field := range fields { 1483 switch field.Name { 1484 case "__typename": 1485 out.Values[i] = graphql.MarshalString("Size") 1486 case "height": 1487 1488 out.Values[i] = ec._Size_height(ctx, field, obj) 1489 1490 if out.Values[i] == graphql.Null { 1491 invalids++ 1492 } 1493 case "weight": 1494 1495 out.Values[i] = ec._Size_weight(ctx, field, obj) 1496 1497 if out.Values[i] == graphql.Null { 1498 invalids++ 1499 } 1500 default: 1501 panic("unknown field " + strconv.Quote(field.Name)) 1502 } 1503 } 1504 out.Dispatch() 1505 if invalids > 0 { 1506 return graphql.Null 1507 } 1508 return out 1509 } 1510 1511 // endregion **************************** object.gotpl **************************** 1512 1513 // region ***************************** type.gotpl ***************************** 1514 1515 func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler { 1516 if v == nil { 1517 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1518 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 1519 } 1520 return graphql.Null 1521 } 1522 return ec._Node(ctx, sel, v) 1523 } 1524 1525 func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler { 1526 if v == nil { 1527 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1528 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 1529 } 1530 return graphql.Null 1531 } 1532 return ec._ShapeUnion(ctx, sel, v) 1533 } 1534 1535 func (ec *executionContext) marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx context.Context, sel ast.SelectionSet, v *Size) graphql.Marshaler { 1536 if v == nil { 1537 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 1538 ec.Errorf(ctx, "the requested element is null which the schema does not allow") 1539 } 1540 return graphql.Null 1541 } 1542 return ec._Size(ctx, sel, v) 1543 } 1544 1545 func (ec *executionContext) marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAnimal(ctx context.Context, sel ast.SelectionSet, v Animal) graphql.Marshaler { 1546 if v == nil { 1547 return graphql.Null 1548 } 1549 return ec._Animal(ctx, sel, v) 1550 } 1551 1552 func (ec *executionContext) marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐBackedByInterface(ctx context.Context, sel ast.SelectionSet, v BackedByInterface) graphql.Marshaler { 1553 if v == nil { 1554 return graphql.Null 1555 } 1556 return ec._BackedByInterface(ctx, sel, v) 1557 } 1558 1559 func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { 1560 if v == nil { 1561 return graphql.Null 1562 } 1563 return ec._Circle(ctx, sel, v) 1564 } 1565 1566 func (ec *executionContext) marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler { 1567 return ec._Coordinates(ctx, sel, &v) 1568 } 1569 1570 func (ec *executionContext) marshalODog2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDog(ctx context.Context, sel ast.SelectionSet, v *Dog) graphql.Marshaler { 1571 if v == nil { 1572 return graphql.Null 1573 } 1574 return ec._Dog(ctx, sel, v) 1575 } 1576 1577 func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { 1578 if v == nil { 1579 return graphql.Null 1580 } 1581 return ec._Shape(ctx, sel, v) 1582 } 1583 1584 func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { 1585 if v == nil { 1586 return graphql.Null 1587 } 1588 ret := make(graphql.Array, len(v)) 1589 var wg sync.WaitGroup 1590 isLen1 := len(v) == 1 1591 if !isLen1 { 1592 wg.Add(len(v)) 1593 } 1594 for i := range v { 1595 i := i 1596 fc := &graphql.FieldContext{ 1597 Index: &i, 1598 Result: &v[i], 1599 } 1600 ctx := graphql.WithFieldContext(ctx, fc) 1601 f := func(i int) { 1602 defer func() { 1603 if r := recover(); r != nil { 1604 ec.Error(ctx, ec.Recover(ctx, r)) 1605 ret = nil 1606 } 1607 }() 1608 if !isLen1 { 1609 defer wg.Done() 1610 } 1611 ret[i] = ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, sel, v[i]) 1612 } 1613 if isLen1 { 1614 f(i) 1615 } else { 1616 go f(i) 1617 } 1618 1619 } 1620 wg.Wait() 1621 1622 return ret 1623 } 1624 1625 // endregion ***************************** type.gotpl *****************************