@@ -39,7 +39,6 @@ import {
3939 isNonNullType ,
4040 isObjectType ,
4141} from '../type/definition.js' ;
42- import { GraphQLDisableErrorPropagationDirective } from '../type/directives.js' ;
4342import type { GraphQLSchema } from '../type/schema.js' ;
4443
4544import {
@@ -134,6 +133,7 @@ export interface ValidatedExecutionArgs {
134133 validatedExecutionArgs : ValidatedExecutionArgs ,
135134 ) => PromiseOrValue < ExecutionResult > ;
136135 hideSuggestions : boolean ;
136+ errorPropagation : boolean ;
137137 abortSignal : AbortSignal | undefined ;
138138}
139139
@@ -181,7 +181,6 @@ export interface ExecutionContext {
181181 collectedErrors : CollectedErrors ;
182182 abortSignalListener : AbortSignalListener | undefined ;
183183 completed : boolean ;
184- errorPropagation : boolean ;
185184}
186185
187186/**
@@ -209,30 +208,6 @@ export interface FormattedExecutionResult<
209208 extensions ?: TExtensions ;
210209}
211210
212- function errorPropagation ( operation : OperationDefinitionNode ) : boolean {
213- const directiveNode = operation . directives ?. find (
214- ( directive ) =>
215- directive . name . value === GraphQLDisableErrorPropagationDirective . name ,
216- ) ;
217-
218- return directiveNode === undefined ;
219- }
220-
221- /**
222- * Implements the "Executing operations" section of the spec.
223- *
224- * Returns a Promise that will eventually resolve to the data described by
225- * The "Response" section of the GraphQL specification.
226- *
227- * If errors are encountered while executing a GraphQL field, only that
228- * field and its descendants will be omitted, and sibling fields will still
229- * be executed. An execution which encounters errors will still result in a
230- * resolved Promise.
231- *
232- * Errors from sub-fields of a NonNull type may propagate to the top level,
233- * at which point we still log the error and null the parent field, which
234- * in this case is the entire response.
235- */
236211export function executeQueryOrMutationOrSubscriptionEvent (
237212 validatedExecutionArgs : ValidatedExecutionArgs ,
238213) : PromiseOrValue < ExecutionResult > {
@@ -244,7 +219,6 @@ export function executeQueryOrMutationOrSubscriptionEvent(
244219 ? new AbortSignalListener ( abortSignal )
245220 : undefined ,
246221 completed : false ,
247- errorPropagation : errorPropagation ( validatedExecutionArgs . operation ) ,
248222 } ;
249223 try {
250224 const {
@@ -575,7 +549,10 @@ function handleFieldError(
575549
576550 // If the field type is non-nullable, then it is resolved without any
577551 // protection from errors, however it still properly locates the error.
578- if ( exeContext . errorPropagation && isNonNullType ( returnType ) ) {
552+ if (
553+ exeContext . validatedExecutionArgs . errorPropagation &&
554+ isNonNullType ( returnType )
555+ ) {
579556 throw error ;
580557 }
581558
0 commit comments