@@ -803,12 +803,19 @@ fragment missingRequiredArg on Arguments {
803
803
804
804
#### Oneof Fields Have Exactly One Argument
805
805
806
- * For each Oneof Field in the document:
807
- * Let {arguments} be the arguments provided by the Field.
808
- * {arguments} must contain exactly one entry.
809
- * For the sole {argument} in {arguments}:
806
+ * For each {operation} in {document}:
807
+ * Let {oneofFields} be all Oneof Fields transitively included in the {operation}.
808
+ * For each {oneofField} in {oneofFields}:
809
+ * Let {arguments} be the arguments provided by {oneofField}.
810
+ * {arguments} must contain exactly one entry.
811
+ * Let {argument} be the sole entry in {arguments}.
810
812
* Let {value} be the value of {argument}.
811
813
* {value} must not be the {null} literal.
814
+ * If {value} is a variable:
815
+ * Let {variableName} be the name of {variable}.
816
+ * Let {variableDefinition} be the {VariableDefinition} named {variableName} defined within {operation}.
817
+ * Let {variableType} be the expected type of {variableDefinition}.
818
+ * {variableType} must be a non-null type.
812
819
813
820
** Explanatory Text**
814
821
@@ -1467,23 +1474,15 @@ input object field is optional.
1467
1474
* Let {oneofInputObjects} be all Oneof Input Objects transitively included in the {operation}.
1468
1475
* For each {oneofInputObject} in {oneofInputObjects}:
1469
1476
* Let {fields} be the fields provided by {oneofInputObject}.
1470
- * {fields} must not be empty.
1471
- * Let {literalFields} be the entries in {fields} that have literal values.
1472
- * If {literalFields} is not empty:
1473
- * {literalFields} must contain exactly one entry.
1474
- * {fields} must contain exactly one entry.
1475
- * For the sole {field} in {literalFields}:
1476
- * Let {value} be the value of {field}.
1477
- * {value} must not be the {null} literal.
1478
- * Otherwise:
1479
- * Let {variableUsages} be all variable usages within {oneofInputObject} directly.
1480
- * Assert: {variableUsages} is not empty.
1481
- * For each {variableUsage} in {variableUsages}:
1482
- * Let {variableName} be the name of {variableUsage}.
1483
- * Let {variableDefinition} be the {VariableDefinition} named {variableName} defined within {operation}.
1484
- * Let {variableType} be the expected type of {variableDefinition}.
1485
- * If {variableType} is a non-null type:
1486
- * {fields} must contain exactly one entry.
1477
+ * {fields} must contain exactly one entry.
1478
+ * Let {field} be the sole entry in {fields}.
1479
+ * Let {value} be the value of {field}.
1480
+ * {value} must not be the {null} literal.
1481
+ * If {value} is a variable:
1482
+ * Let {variableName} be the name of {variable}.
1483
+ * Let {variableDefinition} be the {VariableDefinition} named {variableName} defined within {operation}.
1484
+ * Let {variableType} be the expected type of {variableDefinition}.
1485
+ * {variableType} must be a non-null type.
1487
1486
1488
1487
** Explanatory Text**
1489
1488
@@ -1500,20 +1499,34 @@ query addPet {
1500
1499
}
1501
1500
```
1502
1501
1503
- Multiple fields of a Oneof Input Object may be specified via variables (at most
1504
- one of which may be provided at run time), thus we allow multiple variable
1505
- fields.
1502
+ Multiple fields are not allowed.
1506
1503
1507
- ``` graphgl example
1504
+ ``` graphgl counter- example
1508
1505
query addPet($cat: CatInput, $dog: DogInput) {
1509
1506
addPet(pet: {cat: $cat, dog: $dog}) {
1510
1507
name
1511
1508
}
1512
1509
}
1513
1510
```
1514
1511
1515
- If a field of a Oneof Input Object is specified via a non-nullable variable, no
1516
- other fields may be specified:
1512
+ ``` graphgl counter-example
1513
+ query addPet($dog: DogInput) {
1514
+ addPet(pet: { cat: { name: "Brontie" }, dog: $dog }) {
1515
+ name
1516
+ }
1517
+ }
1518
+ ```
1519
+
1520
+ ``` graphgl counter-example
1521
+ query addPet {
1522
+ addPet(pet: { cat: { name: "Brontie" }, dog: null }) {
1523
+ name
1524
+ }
1525
+ }
1526
+ ```
1527
+
1528
+
1529
+ Variables used for Oneof Input Object fields must be non-nullable.
1517
1530
1518
1531
``` graphgl example
1519
1532
query addPet($cat: CatInput!) {
@@ -1524,15 +1537,16 @@ query addPet($cat: CatInput!) {
1524
1537
```
1525
1538
1526
1539
``` graphgl counter-example
1527
- query addPet($cat: CatInput!, $dog: DogInput ) {
1528
- addPet(pet: { cat: $cat, dog: $dog }) {
1540
+ query addPet($cat: CatInput) {
1541
+ addPet(pet: { cat: $cat }) {
1529
1542
name
1530
1543
}
1531
1544
}
1532
1545
```
1533
1546
1547
+
1534
1548
If a field with a literal value is present then the value must
1535
- not be {null} and no fields with variable values are allowed .
1549
+ not be {null}.
1536
1550
1537
1551
``` graphgl example
1538
1552
query addPet {
@@ -1550,17 +1564,6 @@ query addPet {
1550
1564
}
1551
1565
```
1552
1566
1553
- ``` graphgl counter-example
1554
- query addPet($dog: DogInput) {
1555
- addPet(pet: { cat: { name: "Brontie" }, dog: $dog }) {
1556
- name
1557
- }
1558
- }
1559
- ```
1560
-
1561
- Note: When the fields of a Oneof Input Object are supplied via variables, we
1562
- assert that the input object has exactly one field during coercion.
1563
-
1564
1567
1565
1568
## Directives
1566
1569
0 commit comments