@@ -1859,6 +1859,7 @@ non-null input type as invalid.
1859
1859
**Type Validation **
1860
1860
1861
1861
1. A Non -Null type must not wrap another Non -Null type .
1862
+ 1. A Non -Null type must not wrap a Null -Only -On -Error type .
1862
1863
1863
1864
### Combining List and Non-Null
1864
1865
@@ -1892,6 +1893,79 @@ Following are examples of result coercion with various types and values:
1892
1893
| `[Int !]!` | `[1, 2, null ]` | Error : Item cannot be null |
1893
1894
| `[Int !]!` | `[1, 2, Error ]` | Error : Error occurred in item |
1894
1895
1896
+ ## Null-Only-On-Error
1897
+
1898
+ The GraphQL Null -Only -On -Error type is an alternative to the GraphQL Non -Null
1899
+ type to disallow null unless accompanied by a field error . This type wraps an
1900
+ underlying type , and this type acts identically to that wrapped type , with the
1901
+ exception that {null } will result in a field error being raised . A trailing
1902
+ asterisk is used to denote a field that uses a Null -Only -On -Error type like
1903
+ this : `name : String *`.
1904
+
1905
+ Null -Only -On -Error types are only valid for use as an _output type_ ; they must
1906
+ not be used as an _input type_ .
1907
+
1908
+ **Nullable vs . Optional **
1909
+
1910
+ Fields that return Null -Only -On -Error types will never return the value {null }
1911
+ if queried _unless_ an error has been logged for that field .
1912
+
1913
+ **Result Coercion **
1914
+
1915
+ To coerce the result of a Null -Only -On -Error type , the coercion of the wrapped
1916
+ type should be performed . If that result was not {null }, then the result of
1917
+ coercing the Null -Only -On -Error type is that result . If that result was {null },
1918
+ then a _field error_ must be raised .
1919
+
1920
+ Note : When a _field error_ is raised on a Null -Only -On -Error value , the error
1921
+ does not propagate to the parent field , instead {null } is used for the value .
1922
+ For more information on this process , see
1923
+ [Handling Field Errors ](#sec-Handling-Field-Errors) within the Execution
1924
+ section.
1925
+
1926
+ **Input Coercion**
1927
+
1928
+ Null-Only-On-Error types are never valid inputs.
1929
+
1930
+ **Type Validation**
1931
+
1932
+ 1. A Null-Only-On-Error type must wrap an _output type_.
1933
+ 1. A Null-Only-On-Error type must not wrap another Null-Only-On-Error type.
1934
+ 1. A Null-Only-On-Error type must not wrap a Non-Null type.
1935
+
1936
+ ### Combining List and Null-Only-On-Error
1937
+
1938
+ The List and Null-Only-On-Error wrapping types can compose, representing more
1939
+ complex types. The rules for result coercion of Lists and Null-Only-On-Error
1940
+ types apply in a recursive fashion.
1941
+
1942
+ For example if the inner item type of a List is Null-Only-On-Error (e.g.
1943
+ `[T*]`), then that List may not contain any {null } items unless associated field
1944
+ errors were raised . However if the inner type of a Null -Only -On -Error is a List
1945
+ (e.g. `[T]*`), then {null } is not accepted without an accompanying field error
1946
+ being raised , however an empty list is accepted .
1947
+
1948
+ Following are examples of result coercion with various types and values :
1949
+
1950
+ | Expected Type | Internal Value | Coerced Result |
1951
+ | ------------- | --------------- | ------------------------------------------- |
1952
+ | `[Int ]` | `[1, 2, 3]` | `[1, 2, 3]` |
1953
+ | `[Int ]` | `null ` | `null ` |
1954
+ | `[Int ]` | `[1, 2, null ]` | `[1, 2, null ]` |
1955
+ | `[Int ]` | `[1, 2, Error ]` | `[1, 2, null ]` (With logged error) |
1956
+ | `[Int ]*` | `[1, 2, 3]` | `[1, 2, 3]` |
1957
+ | `[Int ]*` | `null ` | `null ` (With logged coercion error) |
1958
+ | `[Int ]*` | `[1, 2, null ]` | `[1, 2, null ]` |
1959
+ | `[Int ]*` | `[1, 2, Error ]` | `[1, 2, null ]` (With logged error) |
1960
+ | `[Int *]` | `[1, 2, 3]` | `[1, 2, 3]` |
1961
+ | `[Int *]` | `null ` | `null ` |
1962
+ | `[Int *]` | `[1, 2, null ]` | `[1, 2, null ]` (With logged coercion error) |
1963
+ | `[Int *]` | `[1, 2, Error ]` | `[1, 2, null ]` (With logged error) |
1964
+ | `[Int *]*` | `[1, 2, 3]` | `[1, 2, 3]` |
1965
+ | `[Int *]*` | `null ` | `null ` (With logged coercion error) |
1966
+ | `[Int *]*` | `[1, 2, null ]` | `[1, 2, null ]` (With logged coercion error) |
1967
+ | `[Int *]*` | `[1, 2, Error ]` | `[1, 2, null ]` (With logged error) |
1968
+
1895
1969
## Directives
1896
1970
1897
1971
DirectiveDefinition : Description ? directive @ Name ArgumentsDefinition ?
0 commit comments