Skip to content

Commit 2782099

Browse files
committed
language list syntax
1 parent 3cc7af5 commit 2782099

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

spec/Section 2 -- Language.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,14 @@ which returns the result:
518518
## Nullability
519519

520520
Nullability :
521-
- !
522-
- ?
521+
- ListNullability NullabilityModifier?
522+
- NullabilityModifier
523+
524+
ListNullability : `[` Nullability? `]`
525+
526+
NullabilityModifier :
527+
- `!`
528+
- `?`
523529

524530
Fields can have their nullability designated with either a `!` to indicate that a
525531
field should be `Non-Nullable` or a `?` to indicate that a field should be
@@ -572,7 +578,7 @@ in the schema:
572578
```
573579

574580
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
576582
treated as `Nullable` for this operation:
577583

578584
```graphql example
@@ -584,6 +590,30 @@ treated as `Nullable` for this operation:
584590
}
585591
```
586592

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+
Any element without a nullability designator will inherit its nullability from the schema 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.
616+
587617
## Fragments
588618

589619
FragmentSpread : ... FragmentName Directives?

0 commit comments

Comments
 (0)