Skip to content

Commit abfce63

Browse files
committed
fix where cancellation happens for objects
extracted from graphql#4259
1 parent 22df336 commit abfce63

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

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

Lines changed: 6 additions & 6 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
});
@@ -169,8 +169,8 @@ describe('Execute: Cancellation', () => {
169169
errors: [
170170
{
171171
message: 'Aborted',
172-
path: ['todo', 'id'],
173-
locations: [{ line: 4, column: 11 }],
172+
path: ['todo'],
173+
locations: [{ line: 3, column: 9 }],
174174
},
175175
],
176176
});

src/execution/execute.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -534,15 +534,6 @@ function executeFields(
534534
try {
535535
for (const [responseName, fieldDetailsList] of groupedFieldSet) {
536536
const fieldPath = addPath(path, responseName, parentType.name);
537-
const abortSignal = exeContext.validatedExecutionArgs.abortSignal;
538-
if (abortSignal?.aborted) {
539-
throw locatedError(
540-
new Error(abortSignal.reason),
541-
toNodes(fieldDetailsList),
542-
pathToArray(fieldPath),
543-
);
544-
}
545-
546537
const result = executeField(
547538
exeContext,
548539
parentType,
@@ -1273,13 +1264,23 @@ function completeObjectValue(
12731264
path: Path,
12741265
result: unknown,
12751266
): PromiseOrValue<ObjMap<unknown>> {
1267+
const validatedExecutionArgs = exeContext.validatedExecutionArgs;
1268+
const abortSignal = validatedExecutionArgs.abortSignal;
1269+
if (abortSignal?.aborted) {
1270+
throw locatedError(
1271+
new Error(abortSignal.reason),
1272+
toNodes(fieldDetailsList),
1273+
pathToArray(path),
1274+
);
1275+
}
1276+
12761277
// If there is an isTypeOf predicate function, call it with the
12771278
// current result. If isTypeOf returns false, then raise an error rather
12781279
// than continuing execution.
12791280
if (returnType.isTypeOf) {
12801281
const isTypeOf = returnType.isTypeOf(
12811282
result,
1282-
exeContext.validatedExecutionArgs.contextValue,
1283+
validatedExecutionArgs.contextValue,
12831284
info,
12841285
);
12851286

0 commit comments

Comments
 (0)