diff --git a/src/execution/__tests__/abort-signal-test.ts b/src/execution/__tests__/abort-signal-test.ts index 7e34c3dc91..bf3595298a 100644 --- a/src/execution/__tests__/abort-signal-test.ts +++ b/src/execution/__tests__/abort-signal-test.ts @@ -100,8 +100,8 @@ describe('Execute: Cancellation', () => { errors: [ { message: 'Aborted', - path: ['todo', 'id'], - locations: [{ line: 4, column: 11 }], + path: ['todo'], + locations: [{ line: 3, column: 9 }], }, ], }); @@ -149,8 +149,8 @@ describe('Execute: Cancellation', () => { errors: [ { message: 'Aborted', - path: ['todo', 'author', 'id'], - locations: [{ line: 6, column: 13 }], + path: ['todo', 'author'], + locations: [{ line: 5, column: 11 }], }, ], }); @@ -198,8 +198,8 @@ describe('Execute: Cancellation', () => { errors: [ { message: 'Aborted', - path: ['todo', 'id'], - locations: [{ line: 4, column: 11 }], + path: ['todo'], + locations: [{ line: 3, column: 9 }], }, ], }); @@ -257,23 +257,28 @@ describe('Execute: Cancellation', () => { hasNext: true, }, { - completed: [ + incremental: [ { + data: { + text: 'hello world', + author: null, + }, errors: [ { locations: [ { column: 13, - line: 6, + line: 7, }, ], message: 'Aborted', - path: ['todo', 'text'], + path: ['todo', 'author'], }, ], id: '0', }, ], + completed: [{ id: '0' }], hasNext: false, }, ]); diff --git a/src/execution/execute.ts b/src/execution/execute.ts index 5cfb8c1924..427cfc2e1d 100644 --- a/src/execution/execute.ts +++ b/src/execution/execute.ts @@ -729,15 +729,6 @@ function executeFields( try { for (const [responseName, fieldDetailsList] of groupedFieldSet) { const fieldPath = addPath(path, responseName, parentType.name); - const abortSignal = exeContext.validatedExecutionArgs.abortSignal; - if (abortSignal?.aborted) { - throw locatedError( - new Error(abortSignal.reason), - toNodes(fieldDetailsList), - pathToArray(fieldPath), - ); - } - const result = executeField( exeContext, parentType, @@ -1737,13 +1728,23 @@ function completeObjectValue( incrementalContext: IncrementalContext | undefined, deferMap: ReadonlyMap | undefined, ): PromiseOrValue>> { + const validatedExecutionArgs = exeContext.validatedExecutionArgs; + const abortSignal = validatedExecutionArgs.abortSignal; + if (abortSignal?.aborted) { + throw locatedError( + new Error(abortSignal.reason), + toNodes(fieldDetailsList), + pathToArray(path), + ); + } + // If there is an isTypeOf predicate function, call it with the // current result. If isTypeOf returns false, then raise an error rather // than continuing execution. if (returnType.isTypeOf) { const isTypeOf = returnType.isTypeOf( result, - exeContext.validatedExecutionArgs.contextValue, + validatedExecutionArgs.contextValue, info, );