You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/Section 2 -- Language.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -529,16 +529,17 @@ NullabilityModifier :
529
529
Fields can have their nullability designated with either a `!` to indicate that a
530
530
field should be `Non-Nullable` or a `?` to indicate that a field should be
531
531
`Nullable`. These designators override the nullability set on a field by the schema
532
-
for the operation where they're being used. For example, a field marked with `!` in
533
-
a query will be treated identically to a field marked with `!` in the schema for the
534
-
purposes of validation and execution.
532
+
for the operation where they're being used. In addition to being `Non-Nullable`,
533
+
if a field marked with `!` resolves to `null`, it propagates to the nearest parent
534
+
field marked with a `?` or to `data` if one does not exist. An error is added to
535
+
the `errors` array identical to if the field had been `Non-Nullable` in the schema.
535
536
536
537
In this example, we can indicate that a `user`'s `name` that could possibly be
537
-
`null`, should not be `null`:
538
+
`null`, should not be `null` and that `null` propagation should halt at the `user` field:
538
539
539
540
```graphql example
540
541
{
541
-
user(id: 4) {
542
+
user(id: 4)? {
542
543
id
543
544
name!
544
545
}
@@ -608,8 +609,13 @@ applied to multidimensional lists.
608
609
{
609
610
threeDimensionalMatrix[[[?]!]]!
610
611
}
612
+
```
611
613
612
-
Anyelementwithoutanullabilitydesignatorwillinherititsnullabilityfromtheschema definition, exactly the same as non-list fields do. The number of dimensions indicated by
614
+
Any element without a nullability designator will inherit its nullability from the
615
+
schema definition, exactly the same as non-list fields do. When designating
616
+
nullability for list fields, query authors can either use a single designator (`!` or `?`)
617
+
to designate the nullability of the entire field, or they can use the list element
618
+
nullability syntax displayed above. The number of dimensions indicated by
613
619
list element nullability syntax is required to match the number of dimensions of the field.
614
620
Anything else results in a query validation error.
0 commit comments