Skip to content

Commit 38f678c

Browse files
committed
fix(stream): allow initialValue of zero
1 parent 24330c0 commit 38f678c

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/execution/execute.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,26 @@ function completeAsyncIteratorValue(
10321032
let containsPromise = false;
10331033
const stream = getStreamValues(exeContext, fieldNodes);
10341034
return new Promise((resolve) => {
1035-
function next(index, completedResults) {
1035+
function advance(index, completedResults) {
1036+
if (
1037+
stream &&
1038+
typeof stream.initialCount === 'number' &&
1039+
index >= stream.initialCount
1040+
) {
1041+
exeContext.dispatcher.addAsyncIteratorValue(
1042+
stream.label,
1043+
index,
1044+
path,
1045+
iterator,
1046+
exeContext,
1047+
fieldNodes,
1048+
info,
1049+
itemType,
1050+
);
1051+
resolve(completedResults);
1052+
return;
1053+
}
1054+
10361055
const fieldPath = addPath(path, index, undefined);
10371056
iterator.next().then(
10381057
({ value, done }) => {
@@ -1067,26 +1086,7 @@ function completeAsyncIteratorValue(
10671086
return;
10681087
}
10691088

1070-
const newIndex = index + 1;
1071-
if (
1072-
stream &&
1073-
typeof stream.initialCount === 'number' &&
1074-
newIndex >= stream.initialCount
1075-
) {
1076-
exeContext.dispatcher.addAsyncIteratorValue(
1077-
stream.label,
1078-
newIndex,
1079-
path,
1080-
iterator,
1081-
exeContext,
1082-
fieldNodes,
1083-
info,
1084-
itemType,
1085-
);
1086-
resolve(completedResults);
1087-
return;
1088-
}
1089-
next(newIndex, completedResults);
1089+
advance(index + 1, completedResults);
10901090
},
10911091
(rawError) => {
10921092
completedResults.push(null);
@@ -1100,7 +1100,8 @@ function completeAsyncIteratorValue(
11001100
},
11011101
);
11021102
}
1103-
next(0, []);
1103+
1104+
advance(0, []);
11041105
}).then((completedResults) =>
11051106
containsPromise ? Promise.all(completedResults) : completedResults,
11061107
);

0 commit comments

Comments
 (0)