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
Original file line number
Diff line number
Diff line change
@@ -530,16 +530,17 @@ NullabilityModifier :
530
530
Fields can have their nullability designated with either a `!` to indicate that a
531
531
field should be `Non-Nullable` or a `?` to indicate that a field should be
532
532
`Nullable`. These designators override the nullability set on a field by the schema
533
-
for the operation where they're being used. For example, a field marked with `!` in
534
-
a query will be treated identically to a field marked with `!` in the schema for the
535
-
purposes of validation and execution.
533
+
for the operation where they're being used. In addition to being `Non-Nullable`,
534
+
if a field marked with `!` resolves to `null`, it propagates to the nearest parent
535
+
field marked with a `?` or to `data` if one does not exist. An error is added to
536
+
the `errors` array identical to if the field had been `Non-Nullable` in the schema.
536
537
537
538
In this example, we can indicate that a `user`'s `name` that could possibly be
538
-
`null`, should not be `null`:
539
+
`null`, should not be `null` and that `null` propagation should halt at the `user` field:
539
540
540
541
```graphql example
541
542
{
542
-
user(id: 4) {
543
+
user(id: 4)? {
543
544
id
544
545
name!
545
546
}
@@ -609,8 +610,13 @@ applied to multidimensional lists.
609
610
{
610
611
threeDimensionalMatrix[[[?]!]]!
611
612
}
613
+
```
612
614
613
-
Anyelementwithoutanullabilitydesignatorwillinherititsnullabilityfromtheschema definition, exactly the same as non-list fields do. The number of dimensions indicated by
615
+
Any element without a nullability designator will inherit its nullability from the
616
+
schema definition, exactly the same as non-list fields do. When designating
617
+
nullability for list fields, query authors can either use a single designator (`!` or `?`)
618
+
to designate the nullability of the entire field, or they can use the list element
619
+
nullability syntax displayed above. The number of dimensions indicated by
614
620
list element nullability syntax is required to match the number of dimensions of the field.
615
621
Anything else results in a query validation error.
0 commit comments