File tree Expand file tree Collapse file tree 1 file changed +15
-44
lines changed Expand file tree Collapse file tree 1 file changed +15
-44
lines changed Original file line number Diff line number Diff line change @@ -455,68 +455,35 @@ The mechanism for configuring the discriminator field is open to debate, in this
455
455
456
456
### 🎲 Variations
457
457
458
- * Value is the input's type name
459
-
460
- ```graphql
461
- input CatInput {
462
- kind : CatInput
463
- name : String !
464
- age : Int
465
- livesLeft : Int
466
- }
467
- input DogInput {
468
- kind : DogInput
469
- name : String !
470
- age : Int
471
- breed : DogBreed
472
- }
473
-
474
- inputunion AnimalInput @discriminator (field : " kind" ) =
475
- | CatInput
476
- | DogInput
477
-
478
- type Mutation {
479
- logAnimalDropOff (location : String , animals : [AnimalInput ! ]! ): Int
480
- }
481
-
482
- # Variables:
483
- {
484
- location : "Portland, OR" ,
485
- animals : [
486
- {
487
- kind : "CatInput" ,
488
- name : "Buster" ,
489
- livesLeft : 7
490
- }
491
- ]
492
- }
493
- ```
494
-
495
458
* Value is a `Enum` literal
496
459
497
460
This variation is derived from discussions in https://github.com/graphql/graphql-spec/issues/488
498
461
499
462
```graphql
500
- enum AnimalKind {
463
+ enum AnimalSpecies {
501
464
CAT
502
465
DOG
503
466
}
504
467
505
468
input CatInput {
506
- kind : AnimalKind ::CAT
469
+ species : AnimalSpecies ::CAT
507
470
# ...
508
471
}
509
472
input DogInput {
510
- kind : AnimalKind ::DOG
473
+ species : AnimalSpecies ::DOG
511
474
# ...
512
475
}
513
476
477
+ inputunion AnimalInput @discriminator (field : " species" ) =
478
+ | CatInput
479
+ | DogInput
480
+
514
481
# Variables:
515
482
{
516
483
location : "Portland, OR" ,
517
484
animals : [
518
485
{
519
- kind : "CAT" ,
486
+ species : "CAT" ,
520
487
name : "Buster" ,
521
488
livesLeft : 7
522
489
}
@@ -528,20 +495,24 @@ input DogInput {
528
495
529
496
``` graphql
530
497
input CatInput {
531
- kind : "cat "
498
+ species : "Cat "
532
499
# ...
533
500
}
534
501
input DogInput {
535
- kind : "dog "
502
+ species : "Dog "
536
503
# ...
537
504
}
538
505
506
+ inputunion AnimalInput @discriminator (field : " species" ) =
507
+ | CatInput
508
+ | DogInput
509
+
539
510
# Variables:
540
511
{
541
512
location : "Portland, OR" ,
542
513
animals : [
543
514
{
544
- kind : "cat " ,
515
+ species : "Cat " ,
545
516
name : "Buster" ,
546
517
livesLeft : 7
547
518
}
You can’t perform that action at this time.
0 commit comments