Skip to content

Commit e756d23

Browse files
robrichardbenjie
andcommitted
Define response position
Extracted from #1152, without renaming field error to execution error Co-authored-by: Benjie <[email protected]>
1 parent 4abd86e commit e756d23

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

spec/Section 6 -- Execution.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,16 @@ ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
376376
Note: {resultMap} is ordered by which fields appear first in the operation. This
377377
is explained in greater detail in the Field Collection section below.
378378

379-
**Errors and Non-Null Fields**
379+
**Errors and Non-Null Types**
380380

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

385-
If this occurs, any sibling fields which have not yet executed or have not yet
386-
yielded a value may be cancelled to avoid unnecessary work.
387+
If this occurs, any sibling response positions which have not yet executed or
388+
have not yet yielded a value may be cancelled to avoid unnecessary work.
387389

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

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

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

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

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

834-
If all fields from the root of the request to the source of the field error
835-
return `Non-Null` types, then the {"data"} entry in the response should be
836-
{null}.
837+
If all response positions from the root of the request to the source of the
838+
field error return `Non-Null` types, then the {"data"} entry in the response
839+
should be {null}.

spec/Section 7 -- Response.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ be halted.
9393

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

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

@@ -250,8 +252,12 @@ discouraged.
250252

251253
### Path
252254

253-
:: A _path entry_ is an entry within an _error result_ that allows for
254-
association with a particular field reached during GraphQL execution.
255+
:: A _path entry_ is an entry within an _error result_ that indicates the
256+
_response position_ at which the error occurred.
257+
258+
:: A _response position_ is an identifiable position in the response: either a
259+
_field_, or a (potentially nested) list position within a field if the field has
260+
a `List` type.
255261

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

0 commit comments

Comments
 (0)