Skip to content

RFC: Client Controlled Nullability #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
language updated
  • Loading branch information
twof committed Mar 15, 2022
commit b24ce32596d4f8b6e52f664ddf39da915c0eda66
18 changes: 12 additions & 6 deletions spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,16 +530,17 @@ NullabilityModifier :
Fields can have their nullability designated with either a `!` to indicate that a
field should be `Non-Nullable` or a `?` to indicate that a field should be
`Nullable`. These designators override the nullability set on a field by the schema
for the operation where they're being used. For example, a field marked with `!` in
a query will be treated identically to a field marked with `!` in the schema for the
purposes of validation and execution.
for the operation where they're being used. In addition to being `Non-Nullable`,
if a field marked with `!` resolves to `null`, it propagates to the nearest parent
field marked with a `?` or to `data` if one does not exist. An error is added to
the `errors` array identical to if the field had been `Non-Nullable` in the schema.

In this example, we can indicate that a `user`'s `name` that could possibly be
`null`, should not be `null`:
`null`, should not be `null` and that `null` propagation should halt at the `user` field:

```graphql example
{
user(id: 4) {
user(id: 4)? {
id
name!
}
Expand Down Expand Up @@ -609,8 +610,13 @@ applied to multidimensional lists.
{
threeDimensionalMatrix[[[?]!]]!
}
```

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
Any element without a nullability designator will inherit its nullability from the
schema definition, exactly the same as non-list fields do. When designating
nullability for list fields, query authors can either use a single designator (`!` or `?`)
to designate the nullability of the entire field, or they can use the list element
nullability syntax displayed above. The number of dimensions indicated by
list element nullability syntax is required to match the number of dimensions of the field.
Anything else results in a query validation error.

Expand Down