Skip to content

Commit 878c066

Browse files
committed
add first pass at stream implementation to execute
1 parent 8fa38ee commit 878c066

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/execution/execute.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
GraphQLIncludeDirective,
4343
GraphQLSkipDirective,
4444
GraphQLDeferDirective,
45+
GraphQLStreamDirective,
4546
} from '../type/directives';
4647
import {
4748
type GraphQLObjectType,
@@ -1051,10 +1052,46 @@ function completeListValue(
10511052
// No need to modify the info object containing the path,
10521053
// since from here on it is not ever accessed by resolver functions.
10531054
const fieldPath = addPath(path, index);
1055+
const initialFieldNodes = [];
1056+
for (const fieldNode of fieldNodes) {
1057+
const stream = getDirectiveValues(
1058+
GraphQLStreamDirective,
1059+
fieldNode,
1060+
exeContext.variableValues,
1061+
);
1062+
if (
1063+
exeContext.schema.__experimentalStream &&
1064+
stream &&
1065+
stream.if !== false &&
1066+
index >= stream.initial_count
1067+
) {
1068+
const patchErrors = [];
1069+
exeContext.dispatcher.add(
1070+
stream.label,
1071+
fieldPath,
1072+
() =>
1073+
completeValueCatchingError(
1074+
exeContext,
1075+
itemType,
1076+
[fieldNode],
1077+
info,
1078+
fieldPath,
1079+
item,
1080+
patchErrors,
1081+
),
1082+
patchErrors,
1083+
);
1084+
} else {
1085+
initialFieldNodes.push(fieldNode);
1086+
}
1087+
}
1088+
if (!initialFieldNodes.length) {
1089+
return;
1090+
}
10541091
const completedItem = completeValueCatchingError(
10551092
exeContext,
10561093
itemType,
1057-
fieldNodes,
1094+
initialFieldNodes,
10581095
info,
10591096
fieldPath,
10601097
item,

0 commit comments

Comments
 (0)