Skip to content

Commit 3944d05

Browse files
committed
Add error boundary behavior
1 parent 9103fdb commit 3944d05

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

spec/Section 6 -- Execution.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,11 @@ If during {ExecuteSelectionSet()} a field with a non-null {fieldType} raises a
456456
_field error_ then that error must propagate to this entire selection set,
457457
either resolving to {null} if allowed or further propagated to a parent field.
458458

459-
If this occurs, any sibling fields which have not yet executed or have not yet
460-
yielded a value may be cancelled to avoid unnecessary work.
459+
If this occurs, any defer or stream executions with a path that starts with the
460+
same path as the resolved {null} must not return their results to the client.
461+
These defer or stream executions or any sibling fields which have not yet
462+
executed or have not yet yielded a value may be cancelled to avoid unnecessary
463+
work.
461464

462465
Note: See [Handling Field Errors](#sec-Handling-Field-Errors) for more about
463466
this behavior.
@@ -748,7 +751,11 @@ variableValues, parentRecord, subsequentPayloads):
748751
- Wait for the result of {dataExecution} on {parentRecord}.
749752
- If {errors} is not empty:
750753
- Add an entry to {payload} named `errors` with the value {errors}.
751-
- Add an entry to {payload} named `data` with the value {resultMap}.
754+
- If a field error was raised, causing a {null} to be propagated to
755+
{responseValue}, and {objectType} is a Non-Nullable type:
756+
- Add an entry to {payload} named `data` with the value {null}.
757+
- Otherwise:
758+
- Add an entry to {payload} named `data` with the value {resultMap}.
752759
- Add an entry to {payload} named `label` with the value {label}.
753760
- Add an entry to {payload} named `path` with the value {path}.
754761
- Return {payload}.
@@ -923,8 +930,12 @@ variableValues, subsequentPayloads):
923930
- Wait for the result of {dataExecution} on {parentRecord}.
924931
- If {errors} is not empty:
925932
- Add an entry to {payload} named `errors` with the value {errors}.
926-
- Add an entry to {payload} named `items` with a list containing the value
927-
{data}.
933+
- If a field error was raised, causing a {null} to be propagated to {data},
934+
and {innerType} is a Non-Nullable type:
935+
- Add an entry to {payload} named `items` with the value {null}.
936+
- Otherwise:
937+
- Add an entry to {payload} named `items` with a list containing the value
938+
{data}.
928939
- Add an entry to {payload} named `label` with the value {label}.
929940
- Add an entry to {payload} named `path` with the value {itemPath}.
930941
- Return {payload}.
@@ -1100,6 +1111,21 @@ resolves to {null}, then the entire list must resolve to {null}. If the `List`
11001111
type is also wrapped in a `Non-Null`, the field error continues to propagate
11011112
upwards.
11021113

1114+
When a field error is raised inside `ExecuteDeferredFragment` or
1115+
`ExecuteStreamField`, the defer and stream payloads act as error boundaries.
1116+
That is, the null resulting from a `Non-Null` type cannot propagate outside of
1117+
the boundary of the defer or stream payload.
1118+
1119+
If a fragment with the `defer` directive is spread on a Non-Nullable object
1120+
type, and a field error has caused a {null} to propagate to the associated
1121+
object, the {null} should not propagate any further, and the associated Defer
1122+
Payload's `data` field must be set to {null}.
1123+
1124+
If the `stream` directive is present on a list field with a Non-Nullable inner
1125+
type, and a field error has caused a {null} to propagate to the list item, the
1126+
{null} should not propagate any further, and the associated Stream Payload's
1127+
`item` field must be set to {null}.
1128+
11031129
If all fields from the root of the request to the source of the field error
11041130
return `Non-Null` types, then the {"data"} entry in the response should be
11051131
{null}.

0 commit comments

Comments
 (0)