@@ -4,6 +4,8 @@ A GraphQL service generates a response from a request via execution.
44
55:: A _ request_ for execution consists of a few pieces of information:
66
7+ <!-- https://github.com/prettier/prettier/issues/17286 -->
8+ <!-- prettier-ignore -->
79- {schema}: The schema to use, typically solely provided by the GraphQL service.
810- {document}: A {Document} which must contain GraphQL {OperationDefinition} and
911 may contain {FragmentDefinition}.
@@ -15,13 +17,23 @@ A GraphQL service generates a response from a request via execution.
1517 being executed. Conceptually, an initial value represents the "universe" of
1618 data available via a GraphQL Service. It is common for a GraphQL Service to
1719 always use the same initial value for every request.
20+ - {onError} (optional): The _ error behavior_ to apply to the request; see
21+ [ Handling Execution Errors] ( #sec-Handling-Execution-Errors ) . If {onError} is
22+ provided and its value is not one of {"PROPAGATE"}, {"NO_PROPAGATE"}, or
23+ {"ABORT"}, then a _ request error_ must be raised.
1824- {extensions} (optional): A map reserved for implementation-specific additional
1925 information.
2026
2127Given this information, the result of {ExecuteRequest(schema, document,
2228operationName, variableValues, initialValue)} produces the response, to be
2329formatted according to the Response section below.
2430
31+ Note: Previous versions of this specification did not define the {onError}
32+ request attribute. Clients can detect support for {onError} by checking for the
33+ presence of the ` defaultErrorBehavior ` field on the ` __Schema ` introspection
34+ type. If this field is absent, clients should not include {onError} in the
35+ request and must assume the _ error behavior_ is {"PROPAGATE"}.
36+
2537Implementations should not add additional properties to a _ request_ , which may
2638conflict with future editions of the GraphQL specification. Instead,
2739{extensions} provides a reserved location for implementation-specific additional
@@ -392,13 +404,24 @@ is explained in greater detail in the Field Collection section below.
392404</a >
393405
394406If during {ExecuteSelectionSet()} a _ response position_ with a non-null type
395- raises an _ execution error_ then that error must propagate to the parent
396- response position (the entire selection set in the case of a field, or the
397- entire list in the case of a list position), either resolving to {null} if
398- allowed or being further propagated to a parent response position.
399-
400- If this occurs, any sibling response positions which have not yet executed or
401- have not yet yielded a value may be cancelled to avoid unnecessary work.
407+ raises an _ execution error_ , the error must be added to the {"errors"} list in
408+ the _ response_ and then handled according to the _ error behavior_ of the
409+ request:
410+
411+ <!-- https://github.com/prettier/prettier/issues/17286 -->
412+ <!-- prettier-ignore -->
413+ - {"NO\_ PROPAGATE"}: The _ response position_ must be set to {null}. (The client
414+ is responsible for interpreting this {null} in conjunction with the {"errors"}
415+ list to distinguish error results from intentional {null} values.)
416+ - {"PROPAGATE"}: The _ execution error_ must propagate to the parent _ response
417+ position_ (the entire selection set in the case of a field, or the entire list
418+ in the case of a list position). The parent position resolves to {null} if
419+ allowed, or else the error is further propagated to a parent response
420+ position. Any sibling response positions that have not yet executed or have
421+ not yet yielded a value may be cancelled to avoid unnecessary work.
422+ - {"ABORT"}: The entire _ request_ must be aborted. The {"data"} entry in the
423+ _ response_ must be {null}. Any _ response position_ that has not yet executed
424+ or has not yet yielded a value may be cancelled to avoid unnecessary work.
402425
403426Note: See [ Handling Execution Errors] ( #sec-Handling-Execution-Errors ) for more
404427about this behavior.
@@ -823,28 +846,61 @@ MergeSelectionSets(fields):
823846</a >
824847
825848An _ execution error_ is an error raised during field execution, value resolution
826- or coercion, at a specific _ response position_ . While these errors must be
827- reported in the response, they are "handled" by producing partial {"data"} in
828- the _ response_ .
849+ or coercion, at a specific _ response position_ . These errors must be added to
850+ the {"errors"} list in the _ response_ , and are "handled" according to the _ error
851+ behavior_ of the request.
852+
853+ Note: An _ execution error_ is distinct from a _ request error_ which results in a
854+ response with no {"data"}.
855+
856+ If a _ response position_ resolves to {null} because of an execution error which
857+ has already been added to the {"errors"} list in the response, the {"errors"}
858+ list must not be further affected. That is, only one error should be added to
859+ the errors list per _ response position_ .
860+
861+ :: The _ error behavior_ of a request indicates how an _ execution error_ is
862+ handled. It may be specified using the optional {onError} attribute of the
863+ _ request_ . If omitted, the _ default error behavior_ of the schema applies. Valid
864+ values for _ error behavior_ are {"PROPAGATE"}, {"NO_PROPAGATE"} and {"ABORT"}.
865+
866+ :: The _ default error behavior_ of a schema is implementation-defined. For
867+ compatibility with existing clients, schemas should default to {"PROPAGATE"}
868+ which reflects prior behavior. For new schemas, {"NO_PROPAGATE"} is recommended.
869+ The default error behavior is indicated via the ` defaultErrorBehavior ` field of
870+ the ` __Schema ` introspection type, or via the ` @behavior ` schema directive.
871+
872+ Note: {"ABORT"} is not recommended as the _ default error behavior_ because it
873+ prevents generating partial responses which may still contain useful data.
874+
875+ Regardless of error behavior, if a _ response position_ with a non-null type
876+ results in {null} due to the result of {ResolveFieldValue()} then an execution
877+ error must be raised at that position as specified in {CompleteValue()}.
829878
830- Note: This is distinct from a _ request error_ which results in a response with
831- no data.
879+ The _ error behavior_ of a request applies to every _ execution error_ raised
880+ during execution. The following sections describe the behavior of each valid
881+ value:
832882
833- If an execution error is raised while resolving a field (either directly or
834- nested inside any lists), it is handled as though the _ response position_ at
835- which the error occurred resolved to {null}, and the error must be added to the
836- {"errors"} list in the response.
883+ ** {"NO_PROPAGATE"}**
884+
885+ <!-- https://github.com/prettier/prettier/issues/17286 -->
886+ <!-- prettier-ignore -->
887+ With {"NO\_ PROPAGATE"}, a ` Non-Null ` _ response position_ will have the value
888+ {null} if and only if an error occurred at that position.
889+
890+ Note: Clients must inspect the {"errors"} list and use the {"path"} of each
891+ error result to distinguish between intentional {null} values and those
892+ resulting from an _ execution error_ .
893+
894+ ** {"PROPAGATE"}**
895+
896+ With {"PROPAGATE"}, a ` Non-Null ` _ response position_ must not contain {null} in
897+ the _ response_ .
837898
838899If the result of resolving a _ response position_ is {null} (either due to the
839900result of {ResolveFieldValue()} or because an execution error was raised), and
840901that position is of a ` Non-Null ` type, then an execution error is raised at that
841902position. The error must be added to the {"errors"} list in the response.
842903
843- If a _ response position_ resolves to {null} because of an execution error which
844- has already been added to the {"errors"} list in the response, the {"errors"}
845- list must not be further affected. That is, only one error should be added to
846- the errors list per _ response position_ .
847-
848904Since ` Non-Null ` response positions cannot be {null}, execution errors are
849905propagated to be handled by the parent _ response position_ . If the parent
850906response position may be {null} then it resolves to {null}, otherwise if it is a
@@ -859,3 +915,9 @@ position_ must resolve to {null}. If the `List` type is also wrapped in a
859915If every _ response position_ from the root of the request to the source of the
860916execution error has a ` Non-Null ` type, then the {"data"} entry in the response
861917should be {null}.
918+
919+ ** {"ABORT"}**
920+
921+ With {"ABORT"}, execution must cease immediately when the first _ execution
922+ error_ is raised. That error must be added to the {"errors"} list, and {"data"}
923+ must be {null}.
0 commit comments