Skip to content

Commit 051357e

Browse files
robrichardyaacovCR
authored andcommitted
Add error boundary behavior
1 parent 13c7e50 commit 051357e

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
@@ -455,8 +455,11 @@ If during {ExecuteSelectionSet()} a field with a non-null {fieldType} raises a
455455
_field error_ then that error must propagate to this entire selection set,
456456
either resolving to {null} if allowed or further propagated to a parent field.
457457

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

461464
Note: See [Handling Field Errors](#sec-Handling-Field-Errors) for more about
462465
this behavior.
@@ -747,7 +750,11 @@ variableValues, parentRecord, subsequentPayloads):
747750
- Wait for the result of {dataExecution} on {parentRecord}.
748751
- If {errors} is not empty:
749752
- Add an entry to {payload} named `errors` with the value {errors}.
750-
- Add an entry to {payload} named `data` with the value {resultMap}.
753+
- If a field error was raised, causing a {null} to be propagated to
754+
{responseValue}, and {objectType} is a Non-Nullable type:
755+
- Add an entry to {payload} named `data` with the value {null}.
756+
- Otherwise:
757+
- Add an entry to {payload} named `data` with the value {resultMap}.
751758
- Add an entry to {payload} named `label` with the value {label}.
752759
- Add an entry to {payload} named `path` with the value {path}.
753760
- Return {payload}.
@@ -922,8 +929,12 @@ variableValues, subsequentPayloads):
922929
- Wait for the result of {dataExecution} on {parentRecord}.
923930
- If {errors} is not empty:
924931
- Add an entry to {payload} named `errors` with the value {errors}.
925-
- Add an entry to {payload} named `items` with a list containing the value
926-
{data}.
932+
- If a field error was raised, causing a {null} to be propagated to {data},
933+
and {innerType} is a Non-Nullable type:
934+
- Add an entry to {payload} named `items` with the value {null}.
935+
- Otherwise:
936+
- Add an entry to {payload} named `items` with a list containing the value
937+
{data}.
927938
- Add an entry to {payload} named `label` with the value {label}.
928939
- Add an entry to {payload} named `path` with the value {itemPath}.
929940
- Return {payload}.
@@ -1099,6 +1110,21 @@ resolves to {null}, then the entire list must resolve to {null}. If the `List`
10991110
type is also wrapped in a `Non-Null`, the field error continues to propagate
11001111
upwards.
11011112

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

0 commit comments

Comments
 (0)