@@ -58,6 +58,7 @@ import {
5858 collectSubfields as _collectSubfields ,
5959} from './collectFields' ;
6060import { getArgumentValues , getVariableValues } from './values' ;
61+ import { GraphQLErrorBehavior , isErrorBehavior } from '../error/ErrorBehavior' ;
6162
6263/**
6364 * A memoized collection of relevant subfields with regard to the return
@@ -116,7 +117,7 @@ export interface ExecutionContext {
116117 typeResolver : GraphQLTypeResolver < any , any > ;
117118 subscribeFieldResolver : GraphQLFieldResolver < any , any > ;
118119 errors : Array < GraphQLError > ;
119- errorBehavior : 'PROPAGATE' | 'NO_PROPAGATE' | 'ABORT' ;
120+ errorBehavior : GraphQLErrorBehavior ;
120121}
121122
122123/**
@@ -132,6 +133,7 @@ export interface ExecutionResult<
132133> {
133134 errors ?: ReadonlyArray < GraphQLError > ;
134135 data ?: TData | null ;
136+ onError ?: GraphQLErrorBehavior ;
135137 extensions ?: TExtensions ;
136138}
137139
@@ -162,7 +164,7 @@ export interface ExecutionArgs {
162164 *
163165 * @experimental
164166 */
165- onError ?: 'PROPAGATE' | 'NO_PROPAGATE' | 'ABORT' ;
167+ onError ?: GraphQLErrorBehavior ;
166168}
167169
168170/**
@@ -300,12 +302,7 @@ export function buildExecutionContext(
300302 onError,
301303 } = args ;
302304
303- if (
304- onError != null &&
305- onError !== 'PROPAGATE' &&
306- onError !== 'NO_PROPAGATE' &&
307- onError !== 'ABORT'
308- ) {
305+ if ( onError != null && ! isErrorBehavior ( onError ) ) {
309306 return [
310307 new GraphQLError (
311308 'Unsupported `onError` value; supported values are `PROPAGATE`, `NO_PROPAGATE` and `ABORT`.' ,
0 commit comments