Skip to content

Commit ce1b2d7

Browse files
committed
fix where cancellation happens for objects
extracted from #4259
1 parent cf9f785 commit ce1b2d7

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

src/execution/__tests__/abort-signal-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ describe('Execute: Cancellation', () => {
7171
errors: [
7272
{
7373
message: 'Aborted',
74-
path: ['todo', 'id'],
75-
locations: [{ line: 4, column: 11 }],
74+
path: ['todo'],
75+
locations: [{ line: 3, column: 9 }],
7676
},
7777
],
7878
});
@@ -120,8 +120,8 @@ describe('Execute: Cancellation', () => {
120120
errors: [
121121
{
122122
message: 'Aborted',
123-
path: ['todo', 'author', 'id'],
124-
locations: [{ line: 6, column: 13 }],
123+
path: ['todo', 'author'],
124+
locations: [{ line: 5, column: 11 }],
125125
},
126126
],
127127
});

src/execution/execute.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -573,15 +573,6 @@ function executeFields(
573573
try {
574574
for (const [responseName, fieldDetailsList] of groupedFieldSet) {
575575
const fieldPath = addPath(path, responseName, parentType.name);
576-
const abortSignal = exeContext.validatedExecutionArgs.abortSignal;
577-
if (abortSignal?.aborted) {
578-
throw locatedError(
579-
new Error(abortSignal.reason),
580-
toNodes(fieldDetailsList),
581-
pathToArray(fieldPath),
582-
);
583-
}
584-
585576
const result = executeField(
586577
exeContext,
587578
parentType,
@@ -1305,13 +1296,23 @@ function completeObjectValue(
13051296
path: Path,
13061297
result: unknown,
13071298
): PromiseOrValue<ObjMap<unknown>> {
1299+
const validatedExecutionArgs = exeContext.validatedExecutionArgs;
1300+
const abortSignal = validatedExecutionArgs.abortSignal;
1301+
if (abortSignal?.aborted) {
1302+
throw locatedError(
1303+
new Error(abortSignal.reason),
1304+
toNodes(fieldDetailsList),
1305+
pathToArray(path),
1306+
);
1307+
}
1308+
13081309
// If there is an isTypeOf predicate function, call it with the
13091310
// current result. If isTypeOf returns false, then raise an error rather
13101311
// than continuing execution.
13111312
if (returnType.isTypeOf) {
13121313
const isTypeOf = returnType.isTypeOf(
13131314
result,
1314-
exeContext.validatedExecutionArgs.contextValue,
1315+
validatedExecutionArgs.contextValue,
13151316
info,
13161317
);
13171318

0 commit comments

Comments
 (0)