Skip to content

Commit 065a343

Browse files
authored
incrementalDelivery: fix iterable streaming with errors (#3729)
1 parent 612abd3 commit 065a343

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/execution/__tests__/stream-test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,10 +823,7 @@ describe('Execute: stream directive', () => {
823823
}
824824
`);
825825
const result = await complete(document, {
826-
async *scalarList() {
827-
yield await Promise.resolve(friends[0].name);
828-
yield await Promise.resolve({});
829-
},
826+
scalarList: () => [friends[0].name, {}],
830827
});
831828
expectJSON(result).toDeepEqual([
832829
{
@@ -849,9 +846,6 @@ describe('Execute: stream directive', () => {
849846
],
850847
},
851848
],
852-
hasNext: true,
853-
},
854-
{
855849
hasNext: false,
856850
},
857851
]);

src/execution/execute.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,6 @@ function executeStreamField(
18381838
exeContext,
18391839
});
18401840
let completedItem: PromiseOrValue<unknown>;
1841-
let completedItems: PromiseOrValue<Array<unknown> | null>;
18421841
try {
18431842
try {
18441843
if (isPromise(item)) {
@@ -1885,7 +1884,7 @@ function executeStreamField(
18851884
}
18861885
} catch (rawError) {
18871886
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
1888-
completedItems = handleFieldError(
1887+
completedItem = handleFieldError(
18891888
error,
18901889
itemType,
18911890
asyncPayloadRecord.errors,
@@ -1899,6 +1898,7 @@ function executeStreamField(
18991898
return asyncPayloadRecord;
19001899
}
19011900

1901+
let completedItems: PromiseOrValue<Array<unknown> | null>;
19021902
if (isPromise(completedItem)) {
19031903
completedItems = completedItem.then(
19041904
(value) => [value],

0 commit comments

Comments
 (0)