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
+33-3Lines changed: 33 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -519,8 +519,14 @@ which returns the result:
519
519
## Nullability
520
520
521
521
Nullability :
522
-
- !
523
-
- ?
522
+
- ListNullability NullabilityModifier?
523
+
- NullabilityModifier
524
+
525
+
ListNullability : `[` Nullability? `]`
526
+
527
+
NullabilityModifier :
528
+
-`!`
529
+
-`?`
524
530
525
531
Fields can have their nullability designated with either a `!` to indicate that a
526
532
field should be `Non-Nullable` or a `?` to indicate that a field should be
@@ -573,7 +579,7 @@ in the schema:
573
579
```
574
580
575
581
If `user` was `Non-Nullable` in the schema, but we don't want `null`s propagating
576
-
past that point, then we can use `?` to create an error boundary. `User` will be
582
+
past that point, then we can use `?` to create null propagation boundary. `User` will be
577
583
treated as `Nullable` for this operation:
578
584
579
585
```graphql example
@@ -585,6 +591,30 @@ treated as `Nullable` for this operation:
585
591
}
586
592
```
587
593
594
+
Nullability designators can also be applied to list elements like so.
595
+
596
+
```graphql example
597
+
{
598
+
user(id: 4)? {
599
+
id
600
+
petsNames[!]?
601
+
}
602
+
}
603
+
```
604
+
605
+
In the above example, the query author is saying that each individual pet name should be
606
+
`Non-Nullable`, but the list as a whole should be `Nullable`. The same syntax can be
607
+
applied to multidimensional lists.
608
+
609
+
```graphql example
610
+
{
611
+
threeDimensionalMatrix[[[?]!]]!
612
+
}
613
+
614
+
Anyelementwithoutanullabilitydesignatorwillinherititsnullabilityfromtheschema definition, exactly the same as non-list fields do. The number of dimensions indicated by
615
+
list element nullability syntax is required to match the number of dimensions of the field.
616
+
Anything else results in a query validation error.
0 commit comments