@@ -39,10 +39,7 @@ import {
3939 isNonNullType ,
4040 isObjectType ,
4141} from '../type/definition.js' ;
42- import {
43- GraphQLDisableErrorPropagationDirective ,
44- GraphQLStreamDirective ,
45- } from '../type/directives.js' ;
42+ import { GraphQLStreamDirective } from '../type/directives.js' ;
4643import type { GraphQLSchema } from '../type/schema.js' ;
4744
4845import {
@@ -153,6 +150,7 @@ export interface ValidatedExecutionArgs {
153150 ) => PromiseOrValue < ExecutionResult > ;
154151 enableEarlyExecution : boolean ;
155152 hideSuggestions : boolean ;
153+ errorPropagation : boolean ;
156154 abortSignal : AbortSignal | undefined ;
157155}
158156
@@ -162,7 +160,6 @@ export interface ExecutionContext {
162160 abortSignalListener : AbortSignalListener | undefined ;
163161 completed : boolean ;
164162 earlyReturns : Map < StreamRecord , ( ) => Promise < unknown > > | undefined ;
165- errorPropagation : boolean ;
166163}
167164
168165interface IncrementalContext {
@@ -183,15 +180,6 @@ interface GraphQLWrappedResult<T> {
183180 incrementalDataRecords : Array < IncrementalDataRecord > | undefined ;
184181}
185182
186- function errorPropagation ( operation : OperationDefinitionNode ) : boolean {
187- const directiveNode = operation . directives ?. find (
188- ( directive ) =>
189- directive . name . value === GraphQLDisableErrorPropagationDirective . name ,
190- ) ;
191-
192- return directiveNode === undefined ;
193- }
194-
195183export function experimentalExecuteQueryOrMutationOrSubscriptionEvent (
196184 validatedExecutionArgs : ValidatedExecutionArgs ,
197185) : PromiseOrValue < ExecutionResult | ExperimentalIncrementalExecutionResults > {
@@ -204,7 +192,6 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
204192 : undefined ,
205193 completed : false ,
206194 earlyReturns : undefined ,
207- errorPropagation : errorPropagation ( validatedExecutionArgs . operation ) ,
208195 } ;
209196 try {
210197 const {
@@ -763,7 +750,10 @@ function handleFieldError(
763750
764751 // If the field type is non-nullable, then it is resolved without any
765752 // protection from errors, however it still properly locates the error.
766- if ( exeContext . errorPropagation && isNonNullType ( returnType ) ) {
753+ if (
754+ exeContext . validatedExecutionArgs . errorPropagation &&
755+ isNonNullType ( returnType )
756+ ) {
767757 throw error ;
768758 }
769759
0 commit comments