Skip to content

Commit df08928

Browse files
committed
language list syntax
1 parent 9906241 commit df08928

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
@@ -519,8 +519,14 @@ which returns the result:
519519
## Nullability
520520

521521
Nullability :
522-
- !
523-
- ?
522+
- ListNullability NullabilityModifier?
523+
- NullabilityModifier
524+
525+
ListNullability : `[` Nullability? `]`
526+
527+
NullabilityModifier :
528+
- `!`
529+
- `?`
524530

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

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

579585
```graphql example
@@ -585,6 +591,30 @@ treated as `Nullable` for this operation:
585591
}
586592
```
587593

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+
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
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.
617+
588618
## Fragments
589619

590620
FragmentSpread : ... FragmentName Directives?

0 commit comments

Comments
 (0)