Skip to content

Commit 3c83a95

Browse files
committed
remove last extra tick from executeStreamField
requires inlining use of completePromise helper
1 parent b057bc9 commit 3c83a95

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/execution/__tests__/stream-test.ts

-5
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,6 @@ describe('Execute: stream directive', () => {
531531
},
532532
],
533533
},
534-
],
535-
hasNext: true,
536-
},
537-
{
538-
incremental: [
539534
{
540535
items: [{ name: 'Leia', id: '3' }],
541536
path: ['friendList', 2],

src/execution/execute.ts

+20-5
Original file line numberDiff line numberDiff line change
@@ -1956,17 +1956,32 @@ function executeStreamField(
19561956
if (isPromise(item)) {
19571957
const completedItems = (async () => {
19581958
try {
1959-
return [
1960-
await completePromise(
1959+
try {
1960+
const resolved = await item;
1961+
const completed = completeValue(
19611962
exeContext,
19621963
itemType,
19631964
fieldNodes,
19641965
info,
19651966
itemPath,
1966-
item,
1967+
resolved,
19671968
asyncPayloadRecord,
1968-
),
1969-
];
1969+
);
1970+
if (isPromise(completed)) {
1971+
return [await completed];
1972+
}
1973+
return [completed];
1974+
} catch (rawError) {
1975+
const errors = asyncPayloadRecord?.errors ?? exeContext.errors;
1976+
const error = locatedError(
1977+
rawError,
1978+
fieldNodes,
1979+
pathToArray(itemPath),
1980+
);
1981+
const handledError = handleFieldError(error, itemType, errors);
1982+
filterSubsequentPayloads(exeContext, itemPath, asyncPayloadRecord);
1983+
return [handledError];
1984+
}
19701985
} catch (error) {
19711986
asyncPayloadRecord.errors.push(error);
19721987
filterSubsequentPayloads(exeContext, path, asyncPayloadRecord);

0 commit comments

Comments
 (0)