Skip to content

Commit c5b4b38

Browse files
committed
More clarity to Non Null coercion
1 parent 4ff4d7e commit c5b4b38

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

spec/Section 3 -- Type System.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -690,22 +690,33 @@ case), the client can just pass that value rather than constructing the list.
690690

691691
By default, all types in GraphQL are nullable; the {null} value is a valid
692692
response for all of the above types. To declare a type that disallows null,
693-
the GraphQL Non-Null type can be used. This type declares an underlying type,
694-
and this type acts identically to that underlying type, with the exception
693+
the GraphQL Non-Null type can be used. This type wraps an underlying type,
694+
and this type acts identically to that wrapped type, with the exception
695695
that `null` is not a valid response for the wrapping type. A trailing
696696
exclamation mark is used to denote a field that uses a Non-Null type like this:
697697
`name: String!`.
698698

699699
**Result Coercion**
700700

701-
In all of the above result coercion, `null` was considered a valid value.
702-
To coerce the result of a Non Null type, the result coercion of the
703-
underlying type should be performed. If that result was not `null`, then the
704-
result of coercing the Non Null type is that result. If that result was `null`,
705-
then an error should be raised.
701+
In all of the above result coercion, {null} was considered a valid value.
702+
To coerce the result of a Non Null type, the coercion of the wrapped type
703+
should be performed. If that result was not {null}, then the result of coercing
704+
the Non Null type is that result. If that result was {null}, then a field error
705+
must be raised.
706706

707707
**Input Coercion**
708708

709+
If the argument of a Non Null type is not provided, a query error must
710+
be raised.
711+
712+
If an argument of a Non Null type is provided with a literal value, it is
713+
coerced using the input coercion for the wrapped type.
714+
715+
If the argument of a Non Null is provided with a variable, a query error must be
716+
raised if the runtime provided value is not provided or is {null} in the
717+
provided representation (usually JSON). Otherwise, the coerced value is the
718+
result of using the input coercion for the wrapped type.
719+
709720
Note that `null` is not a value in GraphQL, so a query cannot look like:
710721

711722
```!graphql
@@ -714,8 +725,8 @@ Note that `null` is not a value in GraphQL, so a query cannot look like:
714725
}
715726
```
716727

717-
to indicate that the argument is null. Instead, an argument would be null only
718-
if it is omitted:
728+
to indicate that the argument is {null}. Instead, an argument would be {null}
729+
only if it is omitted:
719730

720731
```graphql
721732
{
@@ -732,14 +743,6 @@ query withNullableVariable($var: String) {
732743
}
733744
```
734745

735-
Hence, if the value for a Non Null type is hard-coded in the query, it is always
736-
coerced using the input coercion for the wrapped type.
737-
738-
When a Non Null input has its value set using a variable, a query
739-
error must be raised if the provided value is `null`-like in the
740-
provided representation, or if the provided value is omitted.
741-
Otherwise, the coerced value is the result of running the wrapped
742-
type's input coercion on the provided value.
743746

744747
## Directives
745748

0 commit comments

Comments
 (0)