@@ -710,25 +710,26 @@ and invalid.
710
710
* {arguments} must be the set containing only {argument}.
711
711
712
712
713
- #### Required Non-Null Arguments
713
+ #### Required Arguments
714
714
715
715
* For each Field or Directive in the document.
716
716
* Let {arguments} be the arguments provided by the Field or Directive.
717
717
* Let {argumentDefinitions} be the set of argument definitions of that Field or Directive.
718
- * For each {definition} in {argumentDefinitions}:
719
- * Let {type} be the expected type of {definition}.
720
- * If {type} is Non-Null:
721
- * Let {argumentName} be the name of {definition}.
718
+ * For each {argumentDefinition} in {argumentDefinitions}:
719
+ * Let {type} be the expected type of {argumentDefinition}.
720
+ * Let {defaultValue} be the default value of {argumentDefinition}.
721
+ * If {type} is Non-Null and {defaultValue} does not exist:
722
+ * Let {argumentName} be the name of {argumentDefinition}.
722
723
* Let {argument} be the argument in {arguments} named {argumentName}
723
724
* {argument} must exist.
724
725
* Let {value} be the value of {argument}.
725
726
* {value} must not be the {null} literal.
726
727
727
728
** Explanatory Text**
728
729
729
- Arguments can be required. If the argument type is non-null the argument is
730
- required and furthermore the explicit value {null} may not be provided.
731
- Otherwise, the argument is optional.
730
+ Arguments can be required. If the argument type is non-null and does not have a
731
+ default value, the argument is required and furthermore the explicit value
732
+ {null} may not be provided. Otherwise, the argument is optional.
732
733
733
734
For example the following are valid:
734
735
@@ -738,7 +739,7 @@ fragment goodBooleanArg on Arguments {
738
739
}
739
740
740
741
fragment goodNonNullArg on Arguments {
741
- nonNullBooleanArgField ( nonNullBooleanArg : true )
742
+ requiredBooleanArgField ( requiredBooleanArg : true )
742
743
}
743
744
```
744
745
@@ -752,19 +753,19 @@ fragment goodBooleanArgDefault on Arguments {
752
753
}
753
754
```
754
755
755
- but this is not valid on a non-null argument.
756
+ but this is not valid on a required argument.
756
757
757
758
``` graphql counter-example
758
759
fragment missingRequiredArg on Arguments {
759
- nonNullBooleanArgField
760
+ requiredBooleanArgField
760
761
}
761
762
```
762
763
763
764
Providing the explicit value {null} is also not valid.
764
765
765
766
``` graphql counter-example
766
767
fragment missingRequiredArg on Arguments {
767
- notNullBooleanArgField ( nonNullBooleanArg : null )
768
+ requiredBooleanArgField ( requiredBooleanArg : null )
768
769
}
769
770
```
770
771
@@ -1358,6 +1359,31 @@ For example the following query will not pass validation.
1358
1359
```
1359
1360
1360
1361
1362
+ ### Input Object Required Fields
1363
+
1364
+ ** Formal Specification**
1365
+
1366
+ * For each Input Object in the document.
1367
+ * Let {fields} be the fields provided by that Input Object.
1368
+ * Let {fieldDefinitions} be the set of input field definitions of that Input Object.
1369
+ * For each {fieldDefinition} in {fieldDefinitions}:
1370
+ * Let {type} be the expected type of {fieldDefinition}.
1371
+ * Let {defaultValue} be the default value of {fieldDefinition}.
1372
+ * If {type} is Non-Null and {defaultValue} does not exist:
1373
+ * Let {fieldName} be the name of {fieldDefinition}.
1374
+ * Let {field} be the input field in {fields} named {fieldName}
1375
+ * {field} must exist.
1376
+ * Let {value} be the value of {field}.
1377
+ * {value} must not be the {null} literal.
1378
+
1379
+ ** Explanatory Text**
1380
+
1381
+ Input object fields can be required. If the input object field type is non-null
1382
+ and does not have a default value, the input object field is required and
1383
+ furthermore the explicit value {null} may not be provided. Otherwise, the input
1384
+ object field is optional.
1385
+
1386
+
1361
1387
## Directives
1362
1388
1363
1389
@@ -1494,44 +1520,6 @@ fragment HouseTrainedFragment {
1494
1520
```
1495
1521
1496
1522
1497
- ### Variable Default Value Is Allowed
1498
-
1499
- ** Formal Specification**
1500
-
1501
- * For every Variable Definition {variableDefinition} in a document
1502
- * Let {variableType} be the type of {variableDefinition}
1503
- * Let {defaultValue} be the default value of {variableDefinition}
1504
- * If {variableType} is Non-null:
1505
- * {defaultValue} must be undefined.
1506
-
1507
- ** Explanatory Text**
1508
-
1509
- Variables defined by operations are allowed to define default values
1510
- if the type of that variable is not non-null.
1511
-
1512
- For example the following query will pass validation.
1513
-
1514
- ``` graphql example
1515
- query houseTrainedQuery ($atOtherHomes : Boolean = true ) {
1516
- dog {
1517
- isHousetrained (atOtherHomes : $atOtherHomes )
1518
- }
1519
- }
1520
- ```
1521
-
1522
- However if the variable is defined as non-null, default values
1523
- are unreachable. Therefore queries such as the following fail
1524
- validation
1525
-
1526
- ``` graphql counter-example
1527
- query houseTrainedQuery ($atOtherHomes : Boolean ! = true ) {
1528
- dog {
1529
- isHousetrained (atOtherHomes : $atOtherHomes )
1530
- }
1531
- }
1532
- ```
1533
-
1534
-
1535
1523
### Variables Are Input Types
1536
1524
1537
1525
** Formal Specification**
@@ -1906,8 +1894,12 @@ query booleanArgQuery($booleanArg: Boolean) {
1906
1894
}
1907
1895
```
1908
1896
1909
- A notable exception is when a default value are provided. They are, in effect,
1910
- treated as non-nulls as long as the default value is not {null}.
1897
+ A notable exception is when a default value is provided. Variables which include
1898
+ a default value may be provided to a non-null argument as long as the default
1899
+ value is not {null}.
1900
+
1901
+ Note: The value {null} could still be provided to a variable at runtime, and
1902
+ a non-null argument must produce a field error if provided such a variable.
1911
1903
1912
1904
``` graphql example
1913
1905
query booleanArgQueryWithDefault ($booleanArg : Boolean = true ) {
0 commit comments