Skip to content

Define response position #1158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions spec/Section 6 -- Execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,16 @@ ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
Note: {resultMap} is ordered by which fields appear first in the operation. This
is explained in greater detail in the Field Collection section below.

**Errors and Non-Null Fields**
**Errors and Non-Null Types**

If during {ExecuteSelectionSet()} a field with a non-null {fieldType} raises a
_field error_ then that error must propagate to this entire selection set,
either resolving to {null} if allowed or further propagated to a parent field.
If during {ExecuteSelectionSet()} a _response position_ with a non-null type
raises a _field error_ then that error must propagate to the parent response
position (the entire selection set in the case of a field, or the entire list in
the case of a list position), either resolving to {null} if allowed or being
further propagated to a parent response position.

If this occurs, any sibling fields which have not yet executed or have not yet
yielded a value may be cancelled to avoid unnecessary work.
If this occurs, any sibling response positions which have not yet executed or
have not yet yielded a value may be cancelled to avoid unnecessary work.

Note: See [Handling Field Errors](#sec-Handling-Field-Errors) for more about
this behavior.
Expand Down Expand Up @@ -811,26 +813,27 @@ If a field error is raised while resolving a field, it is handled as though the
field returned {null}, and the error must be added to the {"errors"} list in the
response.

If the result of resolving a field is {null} (either because the function to
resolve the field returned {null} or because a field error was raised), and that
field is of a `Non-Null` type, then a field error is raised. The error must be
added to the {"errors"} list in the response.
If the result of resolving a _response position_ is {null} (either due to the
result of {ResolveFieldValue()} or because a field error was raised), and that
position is of a `Non-Null` type, then a field error is raised at that position.
The error must be added to the {"errors"} list in the response.

If the field returns {null} because of a field error which has already been
added to the {"errors"} list in the response, the {"errors"} list must not be
further affected. That is, only one error should be added to the errors list per
field.
If a _response position_ returns {null} because of a field error which has
already been added to the {"errors"} list in the response, the {"errors"} list
must not be further affected. That is, only one error should be added to the
errors list per _response position_.

Since `Non-Null` type fields cannot be {null}, field errors are propagated to be
handled by the parent field. If the parent field may be {null} then it resolves
to {null}, otherwise if it is a `Non-Null` type, the field error is further
propagated to its parent field.
Since `Non-Null` response positions cannot be {null}, field errors are
propagated to be handled by the parent _response position_. If the parent
response position may be {null} then it resolves to {null}, otherwise if it is a
`Non-Null` type, the field error is further propagated to its parent _response
position_.

If a `List` type wraps a `Non-Null` type, and one of the elements of that list
resolves to {null}, then the entire list must resolve to {null}. If the `List`
type is also wrapped in a `Non-Null`, the field error continues to propagate
upwards.

If all fields from the root of the request to the source of the field error
return `Non-Null` types, then the {"data"} entry in the response should be
{null}.
If every _response position_ from the root of the request to the source of the
field error returns a `Non-Null` type, then the {"data"} entry in the response
should be {null}.
12 changes: 9 additions & 3 deletions spec/Section 7 -- Response.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ be halted.

:: A _field error_ is an error raised during the execution of a particular field
which results in partial response data. This may occur due to an internal error
during value resolution or failure to coerce the resulting value.
during value resolution or failure to coerce the resulting value. A _field
error_ may only occur within a _response position_. The _response position_ is
indicated in the _response_ via the error's _path entry_.

A field error is typically the fault of a GraphQL service.

Expand Down Expand Up @@ -250,8 +252,12 @@ discouraged.

### Path

:: A _path entry_ is an entry within an _error result_ that allows for
association with a particular field reached during GraphQL execution.
:: A _path entry_ is an entry within an _error result_ that indicates the
_response position_ at which the error occurred.

:: A _response position_ is an identifiable position in the response: either a
_field_, or a (potentially nested) list position within a field if the field has
a `List` type.

The value for a _path entry_ must be a list of path segments starting at the
root of the response and ending with the field to be associated with. Path
Expand Down