Skip to content

Commit f4fdc55

Browse files
committed
fix: abortion should not cause incremental completion error
incremental completion errors are indicated if and only if null bubbling has caused a previously sent response to be null it should instead just give a partial response with errors within the incremental array
1 parent cf1c080 commit f4fdc55

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ describe('Execute: Cancellation', () => {
100100
errors: [
101101
{
102102
message: 'Aborted',
103-
path: ['todo', 'id'],
104-
locations: [{ line: 4, column: 11 }],
103+
path: ['todo'],
104+
locations: [{ line: 3, column: 9 }],
105105
},
106106
],
107107
});
@@ -149,8 +149,8 @@ describe('Execute: Cancellation', () => {
149149
errors: [
150150
{
151151
message: 'Aborted',
152-
path: ['todo', 'author', 'id'],
153-
locations: [{ line: 6, column: 13 }],
152+
path: ['todo', 'author'],
153+
locations: [{ line: 5, column: 11 }],
154154
},
155155
],
156156
});
@@ -198,8 +198,8 @@ describe('Execute: Cancellation', () => {
198198
errors: [
199199
{
200200
message: 'Aborted',
201-
path: ['todo', 'id'],
202-
locations: [{ line: 4, column: 11 }],
201+
path: ['todo'],
202+
locations: [{ line: 3, column: 9 }],
203203
},
204204
],
205205
});
@@ -257,23 +257,28 @@ describe('Execute: Cancellation', () => {
257257
hasNext: true,
258258
},
259259
{
260-
completed: [
260+
incremental: [
261261
{
262+
data: {
263+
text: 'hello world',
264+
author: null,
265+
},
262266
errors: [
263267
{
264268
locations: [
265269
{
266270
column: 13,
267-
line: 6,
271+
line: 7,
268272
},
269273
],
270274
message: 'Aborted',
271-
path: ['todo', 'text'],
275+
path: ['todo', 'author'],
272276
},
273277
],
274278
id: '0',
275279
},
276280
],
281+
completed: [{ id: '0' }],
277282
hasNext: false,
278283
},
279284
]);

src/execution/execute.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -729,15 +729,6 @@ function executeFields(
729729
try {
730730
for (const [responseName, fieldDetailsList] of groupedFieldSet) {
731731
const fieldPath = addPath(path, responseName, parentType.name);
732-
const abortSignal = exeContext.validatedExecutionArgs.abortSignal;
733-
if (abortSignal?.aborted) {
734-
throw locatedError(
735-
new Error(abortSignal.reason),
736-
toNodes(fieldDetailsList),
737-
pathToArray(fieldPath),
738-
);
739-
}
740-
741732
const result = executeField(
742733
exeContext,
743734
parentType,
@@ -1737,6 +1728,15 @@ function completeObjectValue(
17371728
incrementalContext: IncrementalContext | undefined,
17381729
deferMap: ReadonlyMap<DeferUsage, DeferredFragmentRecord> | undefined,
17391730
): PromiseOrValue<GraphQLWrappedResult<ObjMap<unknown>>> {
1731+
const abortSignal = exeContext.validatedExecutionArgs.abortSignal;
1732+
if (abortSignal?.aborted) {
1733+
throw locatedError(
1734+
new Error(abortSignal.reason),
1735+
toNodes(fieldDetailsList),
1736+
pathToArray(path),
1737+
);
1738+
}
1739+
17401740
// If there is an isTypeOf predicate function, call it with the
17411741
// current result. If isTypeOf returns false, then raise an error rather
17421742
// than continuing execution.

0 commit comments

Comments
 (0)