@@ -137,7 +137,7 @@ ExecuteQuery(query, schema, variableValues, initialValue):
137
137
- Let {data} be the result of running {ExecuteSelectionSet(selectionSet,
138
138
queryType, initialValue, variableValues)} _ normally_ (allowing
139
139
parallelization).
140
- - Let {errors} be the list of all _ field error_ raised while executing the
140
+ - Let {errors} be the list of all _ runtime error_ raised while executing the
141
141
selection set.
142
142
- Return an unordered map containing {data} and {errors}.
143
143
@@ -158,7 +158,7 @@ ExecuteMutation(mutation, schema, variableValues, initialValue):
158
158
- Let {selectionSet} be the top level selection set in {mutation}.
159
159
- Let {data} be the result of running {ExecuteSelectionSet(selectionSet,
160
160
mutationType, initialValue, variableValues)} _ serially_ .
161
- - Let {errors} be the list of all _ field error_ raised while executing the
161
+ - Let {errors} be the list of all _ runtime error_ raised while executing the
162
162
selection set.
163
163
- Return an unordered map containing {data} and {errors}.
164
164
@@ -317,10 +317,10 @@ MapSourceToResponseEvent(sourceStream, subscription, schema, variableValues):
317
317
- Complete {responseStream} normally.
318
318
- Return {responseStream}.
319
319
320
- Note: Since {ExecuteSubscriptionEvent()} handles all _ field error_ , and _ request
321
- error_ only occur during {CreateSourceEventStream()}, the only remaining error
322
- condition handled from {ExecuteSubscriptionEvent()} are internal exceptional
323
- errors not described by this specification.
320
+ Note: Since {ExecuteSubscriptionEvent()} handles all _ runtime error_ , and
321
+ _ request error_ only occur during {CreateSourceEventStream()}, the only
322
+ remaining error condition handled from {ExecuteSubscriptionEvent()} are internal
323
+ exceptional errors not described by this specification.
324
324
325
325
ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
326
326
@@ -330,7 +330,7 @@ ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue):
330
330
- Let {data} be the result of running {ExecuteSelectionSet(selectionSet,
331
331
subscriptionType, initialValue, variableValues)} _ normally_ (allowing
332
332
parallelization).
333
- - Let {errors} be the list of all _ field error_ raised while executing the
333
+ - Let {errors} be the list of all _ runtime error_ raised while executing the
334
334
selection set.
335
335
- Return an unordered map containing {data} and {errors}.
336
336
@@ -377,16 +377,22 @@ ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
377
377
Note: {resultMap} is ordered by which fields appear first in the operation. This
378
378
is explained in greater detail in the Field Collection section below.
379
379
380
- ** Errors and Non-Null Fields**
380
+ <a name =" sec-Executing-Selection-Sets.Errors-and-Non-Null-Fields " >
381
+ <!-- This link exists for legacy hyperlink support -->
382
+ </a >
381
383
382
- If during {ExecuteSelectionSet()} a field with a non-null {fieldType} raises a
383
- _ field error_ then that error must propagate to this entire selection set,
384
- either resolving to {null} if allowed or further propagated to a parent field.
384
+ ** Errors and Non-Null Types**
385
385
386
- If this occurs, any sibling fields which have not yet executed or have not yet
387
- yielded a value may be cancelled to avoid unnecessary work.
386
+ If during {ExecuteSelectionSet()} a _ response position_ with a non-null type
387
+ raises a _ runtime error_ then that error must propagate to the parent response
388
+ position (the entire selection set in the case of a field, or the entire list in
389
+ the case of a list position), either resolving to {null} if allowed or being
390
+ further propagated to a parent _ response position_ .
388
391
389
- Note: See [ Handling Field Errors] ( #sec-Handling-Field-Errors ) for more about
392
+ If this occurs, any sibling response position which have not yet executed or
393
+ have not yet yielded a value may be cancelled to avoid unnecessary work.
394
+
395
+ Note: See [ Handling Runtime Errors] ( #sec-Handling-Runtime-Errors ) for more about
390
396
this behavior.
391
397
392
398
### Normal and Serial Execution
@@ -647,7 +653,7 @@ CoerceArgumentValues(objectType, field, variableValues):
647
653
- Add an entry to {coercedValues} named {argumentName} with the value
648
654
{defaultValue}.
649
655
- Otherwise if {argumentType} is a Non-Nullable type, and either {hasValue} is
650
- not {true} or {value} is {null}, raise a _ field error_ .
656
+ not {true} or {value} is {null}, raise a _ runtime error_ .
651
657
- Otherwise if {hasValue} is {true}:
652
658
- If {value} is {null}:
653
659
- Add an entry to {coercedValues} named {argumentName} with the value
@@ -657,7 +663,7 @@ CoerceArgumentValues(objectType, field, variableValues):
657
663
{value}.
658
664
- Otherwise:
659
665
- If {value} cannot be coerced according to the input coercion rules of
660
- {argumentType}, raise a _ field error_ .
666
+ {argumentType}, raise a _ runtime error_ .
661
667
- Let {coercedValue} be the result of coercing {value} according to the
662
668
input coercion rules of {argumentType}.
663
669
- Add an entry to {coercedValues} named {argumentName} with the value
@@ -704,12 +710,12 @@ CompleteValue(fieldType, fields, result, variableValues):
704
710
- Let {innerType} be the inner type of {fieldType}.
705
711
- Let {completedResult} be the result of calling {CompleteValue(innerType,
706
712
fields, result, variableValues)}.
707
- - If {completedResult} is {null}, raise a _ field error_ .
713
+ - If {completedResult} is {null}, raise a _ runtime error_ .
708
714
- Return {completedResult}.
709
715
- If {result} is {null} (or another internal value similar to {null} such as
710
716
{undefined}), return {null}.
711
717
- If {fieldType} is a List type:
712
- - If {result} is not a collection of values, raise a _ field error_ .
718
+ - If {result} is not a collection of values, raise a _ runtime error_ .
713
719
- Let {innerType} be the inner type of {fieldType}.
714
720
- Return a list where each list item is the result of calling
715
721
{CompleteValue(innerType, fields, resultItem, variableValues)}, where
@@ -744,7 +750,7 @@ CoerceResult(leafType, value):
744
750
- Return the result of calling the internal method provided by the type system
745
751
for determining the "result coercion" of {leafType} given the value {value}.
746
752
This internal method must return a valid value for the type and not {null}.
747
- Otherwise raise a _ field error_ .
753
+ Otherwise raise a _ runtime error_ .
748
754
749
755
Note: If a field resolver returns {null} then it is handled within
750
756
{CompleteValue()} before {CoerceResult()} is called. Therefore both the input
@@ -799,39 +805,45 @@ MergeSelectionSets(fields):
799
805
- Append all selections in {fieldSelectionSet} to {selectionSet}.
800
806
- Return {selectionSet}.
801
807
802
- ### Handling Field Errors
808
+ <a name =" sec-Handling-Field-Errors " >
809
+ <!-- This link exists for legacy hyperlink support -->
810
+ </a >
811
+
812
+ ### Handling Runtime Errors
803
813
804
- A _ field error_ is an error raised from a particular field during value
814
+ A _ runtime error_ is an error raised from a particular field during value
805
815
resolution or coercion. While these errors should be reported in the response,
806
816
they are "handled" by producing a partial response.
807
817
808
818
Note: This is distinct from a _ request error_ which results in a response with
809
819
no data.
810
820
811
- If a field error is raised while resolving a field, it is handled as though the
812
- field returned {null}, and the error must be added to the {"errors"} list in the
813
- response.
821
+ If a runtime error is raised while resolving a field (either directly or nested
822
+ inside any lists), it is handled as though the position at which the error
823
+ occurred resulted in {null}, and the error must be added to the {"errors"} list
824
+ in the response.
814
825
815
- If the result of resolving a field is {null} (either because the function to
816
- resolve the field returned {null } or because a field error was raised), and that
817
- field is of a ` Non-Null ` type, then a field error is raised. The error must be
818
- added to the {"errors"} list in the response.
826
+ If the result of resolving a _ response position _ is {null} (either due to the
827
+ result of {ResolveFieldValue() } or because a runtime error was raised), and that
828
+ position is of a ` Non-Null ` type, then a runtime error is raised at that
829
+ position. The error must be added to the {"errors"} list in the response.
819
830
820
- If the field returns {null} because of a field error which has already been
821
- added to the {"errors"} list in the response, the {"errors"} list must not be
822
- further affected. That is, only one error should be added to the errors list per
823
- field .
831
+ If a _ response position _ returns {null} because of a runtime error which has
832
+ already been added to the {"errors"} list in the response, the {"errors"} list
833
+ must not be further affected. That is, only one error should be added to the
834
+ errors list per _ response position _ .
824
835
825
- Since ` Non-Null ` type fields cannot be {null}, field errors are propagated to be
826
- handled by the parent field. If the parent field may be {null} then it resolves
827
- to {null}, otherwise if it is a ` Non-Null ` type, the field error is further
828
- propagated to its parent field.
836
+ Since ` Non-Null ` response positions cannot be {null}, runtime errors are
837
+ propagated to be handled by the parent _ response position_ . If the parent
838
+ response position may be {null} then it resolves to {null}, otherwise if it is a
839
+ ` Non-Null ` type, the runtime error is further propagated to its parent _ response
840
+ position_ .
829
841
830
842
If a ` List ` type wraps a ` Non-Null ` type, and one of the elements of that list
831
843
resolves to {null}, then the entire list must resolve to {null}. If the ` List `
832
- type is also wrapped in a ` Non-Null ` , the field error continues to propagate
844
+ type is also wrapped in a ` Non-Null ` , the runtime error continues to propagate
833
845
upwards.
834
846
835
- If all fields from the root of the request to the source of the field error
836
- return ` Non-Null ` types, then the {"data"} entry in the response should be
837
- {null}.
847
+ If all response positions from the root of the request to the source of the
848
+ runtime error return ` Non-Null ` types, then the {"data"} entry in the response
849
+ should be {null}.
0 commit comments