Skip to content

Commit 910b694

Browse files
authored
Improve clarity for treating null for List values (#213)
As mentioned in #83, we had left the treatment of input `null` by a List value ambiguous, while there is an intended behavior. Because of the existing language, it's easy to misinterpret providing `null` to `[String]` as the value `[null]`, while the correct interpretating would be `null`.
1 parent ba1bbe5 commit 910b694

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

spec/Section 3 -- Type System.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -814,11 +814,16 @@ implementation.
814814
When expected as an input, list values are accepted only when each item in the
815815
list can be accepted by the list's item type.
816816

817-
If the value passed as an input to a list type is *not* as list, it should be
818-
coerced as though the input was a list of size one, where the value passed is
819-
the only item in the list. This is to allow inputs that accept a "var args"
820-
to declare their input type as a list; if only one argument is passed (a common
821-
case), the client can just pass that value rather than constructing the list.
817+
If the value passed as an input to a list type is *not* a list and not the
818+
{null} value, it should be coerced as though the input was a list of size one,
819+
where the value passed is the only item in the list. This is to allow inputs
820+
that accept a "var args" to declare their input type as a list; if only one
821+
argument is passed (a common case), the client can just pass that value rather
822+
than constructing the list.
823+
824+
Note that when a {null} value is provided via a runtime variable value for a
825+
list type that it is interpretted as no list being provided, and not a list of
826+
size one with the value {null}.
822827

823828

824829
### Non-Null
@@ -878,7 +883,7 @@ query withNullableVariable($var: String) {
878883
}
879884
```
880885

881-
#### Non-Null type validation
886+
**Non-Null type validation**
882887

883888
1. A Non-Null type must not wrap another Non-Null type.
884889

0 commit comments

Comments
 (0)