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