Skip to content

Commit ed12965

Browse files
committed
Add examples and clarify wording/algorithm
1 parent fa905f1 commit ed12965

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

spec/Section 5 -- Validation.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ set is ambiguous and invalid.
993993

994994
**Explanatory Text**
995995

996-
Arguments can be required. An argument is required if the argument type is
996+
Arguments can be required. An argument is required if the expected type is
997997
non-null and does not have a default value. Otherwise, the argument is optional.
998998

999999
For example the following are valid:
@@ -1035,7 +1035,19 @@ fragment missingRequiredArg on Arguments {
10351035
}
10361036
```
10371037

1038-
Fragment arguments can also be the source of the default value:
1038+
Fragments can also have required arguments, making this invalid:
1039+
1040+
```graphql counter-example
1041+
fragment fragmentWithNonNullVariable($arg: Boolean!) on Arguments {
1042+
nonNullBooleanArgField(nonNullBooleanArg: $arg)
1043+
}
1044+
1045+
fragment goodFragmentDefault on Arguments {
1046+
...fragmentWithNonNullVariable
1047+
}
1048+
```
1049+
1050+
but fragment variables can have defaults, making the argument optional:
10391051

10401052
```graphql example
10411053
fragment fragmentWithDefault($arg: Boolean! = true) on Arguments {
@@ -1806,8 +1818,9 @@ query ($foo: Boolean = true, $bar: Boolean = false) {
18061818

18071819
**Formal Specification**
18081820

1809-
- For every {operation} and {fragment} in the document:
1810-
- Let {operationOrFragment} be that {operation} or {fragment}.
1821+
- Let {operationsAndFragments} be the set of all operation and fragment
1822+
definitions in the document.
1823+
- For each {operationOrFragment} in {operationsAndFragments}:
18111824
- For every {variable} defined on {operationOrFragment}:
18121825
- Let {variableName} be the name of {variable}.
18131826
- Let {variables} be the set of all variables named {variableName} on

0 commit comments

Comments
 (0)