github.com/operandinc/gqlgen@v0.16.1/codegen/testserver/followschema/nulls.generated.go (about) 1 // Code generated by github.com/operandinc/gqlgen, DO NOT EDIT. 2 3 package followschema 4 5 import ( 6 "context" 7 "strconv" 8 "sync" 9 "sync/atomic" 10 11 "github.com/operandinc/gqlgen/graphql" 12 "github.com/vektah/gqlparser/v2/ast" 13 ) 14 15 // region ************************** generated!.gotpl ************************** 16 17 type ErrorsResolver interface { 18 A(ctx context.Context, obj *Errors) (*Error, error) 19 B(ctx context.Context, obj *Errors) (*Error, error) 20 C(ctx context.Context, obj *Errors) (*Error, error) 21 D(ctx context.Context, obj *Errors) (*Error, error) 22 E(ctx context.Context, obj *Errors) (*Error, error) 23 } 24 25 // endregion ************************** generated!.gotpl ************************** 26 27 // region ***************************** args.gotpl ***************************** 28 29 // endregion ***************************** args.gotpl ***************************** 30 31 // region ************************** directives.gotpl ************************** 32 33 // endregion ************************** directives.gotpl ************************** 34 35 // region **************************** field.gotpl ***************************** 36 37 func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { 38 defer func() { 39 if r := recover(); r != nil { 40 ec.Error(ctx, ec.Recover(ctx, r)) 41 ret = graphql.Null 42 } 43 }() 44 fc := &graphql.FieldContext{ 45 Object: "Error", 46 Field: field, 47 Args: nil, 48 IsMethod: false, 49 IsResolver: false, 50 } 51 52 ctx = graphql.WithFieldContext(ctx, fc) 53 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 54 ctx = rctx // use context from middleware stack in children 55 return obj.ID, nil 56 }) 57 58 if resTmp == nil { 59 if !graphql.HasFieldError(ctx, fc) { 60 ec.Errorf(ctx, "must not be null") 61 } 62 return graphql.Null 63 } 64 res := resTmp.(string) 65 fc.Result = res 66 return ec.marshalNID2string(ctx, field.Selections, res) 67 } 68 69 func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { 70 defer func() { 71 if r := recover(); r != nil { 72 ec.Error(ctx, ec.Recover(ctx, r)) 73 ret = graphql.Null 74 } 75 }() 76 fc := &graphql.FieldContext{ 77 Object: "Error", 78 Field: field, 79 Args: nil, 80 IsMethod: true, 81 IsResolver: false, 82 } 83 84 ctx = graphql.WithFieldContext(ctx, fc) 85 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 86 ctx = rctx // use context from middleware stack in children 87 return obj.ErrorOnNonRequiredField() 88 }) 89 90 if resTmp == nil { 91 return graphql.Null 92 } 93 res := resTmp.(string) 94 fc.Result = res 95 return ec.marshalOString2string(ctx, field.Selections, res) 96 } 97 98 func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { 99 defer func() { 100 if r := recover(); r != nil { 101 ec.Error(ctx, ec.Recover(ctx, r)) 102 ret = graphql.Null 103 } 104 }() 105 fc := &graphql.FieldContext{ 106 Object: "Error", 107 Field: field, 108 Args: nil, 109 IsMethod: true, 110 IsResolver: false, 111 } 112 113 ctx = graphql.WithFieldContext(ctx, fc) 114 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 115 ctx = rctx // use context from middleware stack in children 116 return obj.ErrorOnRequiredField() 117 }) 118 119 if resTmp == nil { 120 if !graphql.HasFieldError(ctx, fc) { 121 ec.Errorf(ctx, "must not be null") 122 } 123 return graphql.Null 124 } 125 res := resTmp.(string) 126 fc.Result = res 127 return ec.marshalNString2string(ctx, field.Selections, res) 128 } 129 130 func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { 131 defer func() { 132 if r := recover(); r != nil { 133 ec.Error(ctx, ec.Recover(ctx, r)) 134 ret = graphql.Null 135 } 136 }() 137 fc := &graphql.FieldContext{ 138 Object: "Error", 139 Field: field, 140 Args: nil, 141 IsMethod: true, 142 IsResolver: false, 143 } 144 145 ctx = graphql.WithFieldContext(ctx, fc) 146 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 147 ctx = rctx // use context from middleware stack in children 148 return obj.NilOnRequiredField(), nil 149 }) 150 151 if resTmp == nil { 152 if !graphql.HasFieldError(ctx, fc) { 153 ec.Errorf(ctx, "must not be null") 154 } 155 return graphql.Null 156 } 157 res := resTmp.(*string) 158 fc.Result = res 159 return ec.marshalNString2ᚖstring(ctx, field.Selections, res) 160 } 161 162 func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { 163 defer func() { 164 if r := recover(); r != nil { 165 ec.Error(ctx, ec.Recover(ctx, r)) 166 ret = graphql.Null 167 } 168 }() 169 fc := &graphql.FieldContext{ 170 Object: "Errors", 171 Field: field, 172 Args: nil, 173 IsMethod: true, 174 IsResolver: true, 175 } 176 177 ctx = graphql.WithFieldContext(ctx, fc) 178 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 179 ctx = rctx // use context from middleware stack in children 180 return ec.resolvers.Errors().A(rctx, obj) 181 }) 182 183 if resTmp == nil { 184 if !graphql.HasFieldError(ctx, fc) { 185 ec.Errorf(ctx, "must not be null") 186 } 187 return graphql.Null 188 } 189 res := resTmp.(*Error) 190 fc.Result = res 191 return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) 192 } 193 194 func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { 195 defer func() { 196 if r := recover(); r != nil { 197 ec.Error(ctx, ec.Recover(ctx, r)) 198 ret = graphql.Null 199 } 200 }() 201 fc := &graphql.FieldContext{ 202 Object: "Errors", 203 Field: field, 204 Args: nil, 205 IsMethod: true, 206 IsResolver: true, 207 } 208 209 ctx = graphql.WithFieldContext(ctx, fc) 210 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 211 ctx = rctx // use context from middleware stack in children 212 return ec.resolvers.Errors().B(rctx, obj) 213 }) 214 215 if resTmp == nil { 216 if !graphql.HasFieldError(ctx, fc) { 217 ec.Errorf(ctx, "must not be null") 218 } 219 return graphql.Null 220 } 221 res := resTmp.(*Error) 222 fc.Result = res 223 return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) 224 } 225 226 func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { 227 defer func() { 228 if r := recover(); r != nil { 229 ec.Error(ctx, ec.Recover(ctx, r)) 230 ret = graphql.Null 231 } 232 }() 233 fc := &graphql.FieldContext{ 234 Object: "Errors", 235 Field: field, 236 Args: nil, 237 IsMethod: true, 238 IsResolver: true, 239 } 240 241 ctx = graphql.WithFieldContext(ctx, fc) 242 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 243 ctx = rctx // use context from middleware stack in children 244 return ec.resolvers.Errors().C(rctx, obj) 245 }) 246 247 if resTmp == nil { 248 if !graphql.HasFieldError(ctx, fc) { 249 ec.Errorf(ctx, "must not be null") 250 } 251 return graphql.Null 252 } 253 res := resTmp.(*Error) 254 fc.Result = res 255 return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) 256 } 257 258 func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { 259 defer func() { 260 if r := recover(); r != nil { 261 ec.Error(ctx, ec.Recover(ctx, r)) 262 ret = graphql.Null 263 } 264 }() 265 fc := &graphql.FieldContext{ 266 Object: "Errors", 267 Field: field, 268 Args: nil, 269 IsMethod: true, 270 IsResolver: true, 271 } 272 273 ctx = graphql.WithFieldContext(ctx, fc) 274 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 275 ctx = rctx // use context from middleware stack in children 276 return ec.resolvers.Errors().D(rctx, obj) 277 }) 278 279 if resTmp == nil { 280 if !graphql.HasFieldError(ctx, fc) { 281 ec.Errorf(ctx, "must not be null") 282 } 283 return graphql.Null 284 } 285 res := resTmp.(*Error) 286 fc.Result = res 287 return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) 288 } 289 290 func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { 291 defer func() { 292 if r := recover(); r != nil { 293 ec.Error(ctx, ec.Recover(ctx, r)) 294 ret = graphql.Null 295 } 296 }() 297 fc := &graphql.FieldContext{ 298 Object: "Errors", 299 Field: field, 300 Args: nil, 301 IsMethod: true, 302 IsResolver: true, 303 } 304 305 ctx = graphql.WithFieldContext(ctx, fc) 306 resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { 307 ctx = rctx // use context from middleware stack in children 308 return ec.resolvers.Errors().E(rctx, obj) 309 }) 310 311 if resTmp == nil { 312 if !graphql.HasFieldError(ctx, fc) { 313 ec.Errorf(ctx, "must not be null") 314 } 315 return graphql.Null 316 } 317 res := resTmp.(*Error) 318 fc.Result = res 319 return ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) 320 } 321 322 // endregion **************************** field.gotpl ***************************** 323 324 // region **************************** input.gotpl ***************************** 325 326 // endregion **************************** input.gotpl ***************************** 327 328 // region ************************** interface.gotpl *************************** 329 330 // endregion ************************** interface.gotpl *************************** 331 332 // region **************************** object.gotpl **************************** 333 334 var errorImplementors = []string{"Error"} 335 336 func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler { 337 fields := graphql.CollectFields(ec.OperationContext, sel, errorImplementors) 338 out := graphql.NewFieldSet(fields) 339 var invalids uint32 340 for i, field := range fields { 341 switch field.Name { 342 case "__typename": 343 out.Values[i] = graphql.MarshalString("Error") 344 case "id": 345 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 346 return ec._Error_id(ctx, field, obj) 347 } 348 349 out.Values[i] = innerFunc(ctx) 350 351 if out.Values[i] == graphql.Null { 352 invalids++ 353 } 354 case "errorOnNonRequiredField": 355 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 356 return ec._Error_errorOnNonRequiredField(ctx, field, obj) 357 } 358 359 out.Values[i] = innerFunc(ctx) 360 361 case "errorOnRequiredField": 362 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 363 return ec._Error_errorOnRequiredField(ctx, field, obj) 364 } 365 366 out.Values[i] = innerFunc(ctx) 367 368 if out.Values[i] == graphql.Null { 369 invalids++ 370 } 371 case "nilOnRequiredField": 372 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 373 return ec._Error_nilOnRequiredField(ctx, field, obj) 374 } 375 376 out.Values[i] = innerFunc(ctx) 377 378 if out.Values[i] == graphql.Null { 379 invalids++ 380 } 381 default: 382 panic("unknown field " + strconv.Quote(field.Name)) 383 } 384 } 385 out.Dispatch() 386 if invalids > 0 { 387 return graphql.Null 388 } 389 return out 390 } 391 392 var errorsImplementors = []string{"Errors"} 393 394 func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, obj *Errors) graphql.Marshaler { 395 fields := graphql.CollectFields(ec.OperationContext, sel, errorsImplementors) 396 out := graphql.NewFieldSet(fields) 397 var invalids uint32 398 for i, field := range fields { 399 switch field.Name { 400 case "__typename": 401 out.Values[i] = graphql.MarshalString("Errors") 402 case "a": 403 field := field 404 405 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 406 defer func() { 407 if r := recover(); r != nil { 408 ec.Error(ctx, ec.Recover(ctx, r)) 409 } 410 }() 411 res = ec._Errors_a(ctx, field, obj) 412 if res == graphql.Null { 413 atomic.AddUint32(&invalids, 1) 414 } 415 return res 416 } 417 418 out.Concurrently(i, func() graphql.Marshaler { 419 return innerFunc(ctx) 420 421 }) 422 case "b": 423 field := field 424 425 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 426 defer func() { 427 if r := recover(); r != nil { 428 ec.Error(ctx, ec.Recover(ctx, r)) 429 } 430 }() 431 res = ec._Errors_b(ctx, field, obj) 432 if res == graphql.Null { 433 atomic.AddUint32(&invalids, 1) 434 } 435 return res 436 } 437 438 out.Concurrently(i, func() graphql.Marshaler { 439 return innerFunc(ctx) 440 441 }) 442 case "c": 443 field := field 444 445 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 446 defer func() { 447 if r := recover(); r != nil { 448 ec.Error(ctx, ec.Recover(ctx, r)) 449 } 450 }() 451 res = ec._Errors_c(ctx, field, obj) 452 if res == graphql.Null { 453 atomic.AddUint32(&invalids, 1) 454 } 455 return res 456 } 457 458 out.Concurrently(i, func() graphql.Marshaler { 459 return innerFunc(ctx) 460 461 }) 462 case "d": 463 field := field 464 465 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 466 defer func() { 467 if r := recover(); r != nil { 468 ec.Error(ctx, ec.Recover(ctx, r)) 469 } 470 }() 471 res = ec._Errors_d(ctx, field, obj) 472 if res == graphql.Null { 473 atomic.AddUint32(&invalids, 1) 474 } 475 return res 476 } 477 478 out.Concurrently(i, func() graphql.Marshaler { 479 return innerFunc(ctx) 480 481 }) 482 case "e": 483 field := field 484 485 innerFunc := func(ctx context.Context) (res graphql.Marshaler) { 486 defer func() { 487 if r := recover(); r != nil { 488 ec.Error(ctx, ec.Recover(ctx, r)) 489 } 490 }() 491 res = ec._Errors_e(ctx, field, obj) 492 if res == graphql.Null { 493 atomic.AddUint32(&invalids, 1) 494 } 495 return res 496 } 497 498 out.Concurrently(i, func() graphql.Marshaler { 499 return innerFunc(ctx) 500 501 }) 502 default: 503 panic("unknown field " + strconv.Quote(field.Name)) 504 } 505 } 506 out.Dispatch() 507 if invalids > 0 { 508 return graphql.Null 509 } 510 return out 511 } 512 513 // endregion **************************** object.gotpl **************************** 514 515 // region ***************************** type.gotpl ***************************** 516 517 func (ec *executionContext) marshalNError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { 518 return ec._Error(ctx, sel, &v) 519 } 520 521 func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { 522 if v == nil { 523 if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 524 ec.Errorf(ctx, "must not be null") 525 } 526 return graphql.Null 527 } 528 return ec._Error(ctx, sel, v) 529 } 530 531 func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler { 532 if v == nil { 533 return graphql.Null 534 } 535 ret := make(graphql.Array, len(v)) 536 var wg sync.WaitGroup 537 isLen1 := len(v) == 1 538 if !isLen1 { 539 wg.Add(len(v)) 540 } 541 for i := range v { 542 i := i 543 fc := &graphql.FieldContext{ 544 Index: &i, 545 Result: &v[i], 546 } 547 ctx := graphql.WithFieldContext(ctx, fc) 548 f := func(i int) { 549 defer func() { 550 if r := recover(); r != nil { 551 ec.Error(ctx, ec.Recover(ctx, r)) 552 ret = nil 553 } 554 }() 555 if !isLen1 { 556 defer wg.Done() 557 } 558 ret[i] = ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, sel, v[i]) 559 } 560 if isLen1 { 561 f(i) 562 } else { 563 go f(i) 564 } 565 566 } 567 wg.Wait() 568 569 return ret 570 } 571 572 func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler { 573 if v == nil { 574 return graphql.Null 575 } 576 ret := make(graphql.Array, len(v)) 577 var wg sync.WaitGroup 578 isLen1 := len(v) == 1 579 if !isLen1 { 580 wg.Add(len(v)) 581 } 582 for i := range v { 583 i := i 584 fc := &graphql.FieldContext{ 585 Index: &i, 586 Result: &v[i], 587 } 588 ctx := graphql.WithFieldContext(ctx, fc) 589 f := func(i int) { 590 defer func() { 591 if r := recover(); r != nil { 592 ec.Error(ctx, ec.Recover(ctx, r)) 593 ret = nil 594 } 595 }() 596 if !isLen1 { 597 defer wg.Done() 598 } 599 ret[i] = ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, sel, v[i]) 600 } 601 if isLen1 { 602 f(i) 603 } else { 604 go f(i) 605 } 606 607 } 608 wg.Wait() 609 610 for _, e := range ret { 611 if e == graphql.Null { 612 return graphql.Null 613 } 614 } 615 616 return ret 617 } 618 619 func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { 620 if v == nil { 621 return graphql.Null 622 } 623 return ec._Error(ctx, sel, v) 624 } 625 626 func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler { 627 if v == nil { 628 return graphql.Null 629 } 630 return ec._Errors(ctx, sel, v) 631 } 632 633 // endregion ***************************** type.gotpl *****************************