Skip to content

Commit c1d3868

Browse files
robrichardlilianammmatos
authored andcommitted
add first pass at stream implementation to execute
1 parent d9f5919 commit c1d3868

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
@@ -43,6 +43,7 @@ import {
4343
GraphQLIncludeDirective,
4444
GraphQLSkipDirective,
4545
GraphQLDeferDirective,
46+
GraphQLStreamDirective,
4647
} from '../type/directives';
4748
import {
4849
type GraphQLObjectType,
@@ -1054,10 +1055,46 @@ function completeListValue(
10541055
// No need to modify the info object containing the path,
10551056
// since from here on it is not ever accessed by resolver functions.
10561057
const fieldPath = addPath(path, index);
1058+
const initialFieldNodes = [];
1059+
for (const fieldNode of fieldNodes) {
1060+
const stream = getDirectiveValues(
1061+
GraphQLStreamDirective,
1062+
fieldNode,
1063+
exeContext.variableValues,
1064+
);
1065+
if (
1066+
exeContext.schema.__experimentalStream &&
1067+
stream &&
1068+
stream.if !== false &&
1069+
index >= stream.initial_count
1070+
) {
1071+
const patchErrors = [];
1072+
exeContext.dispatcher.add(
1073+
stream.label,
1074+
fieldPath,
1075+
() =>
1076+
completeValueCatchingError(
1077+
exeContext,
1078+
itemType,
1079+
[fieldNode],
1080+
info,
1081+
fieldPath,
1082+
item,
1083+
patchErrors,
1084+
),
1085+
patchErrors,
1086+
);
1087+
} else {
1088+
initialFieldNodes.push(fieldNode);
1089+
}
1090+
}
1091+
if (!initialFieldNodes.length) {
1092+
return;
1093+
}
10571094
const completedItem = completeValueCatchingError(
10581095
exeContext,
10591096
itemType,
1060-
fieldNodes,
1097+
initialFieldNodes,
10611098
info,
10621099
fieldPath,
10631100
item,

0 commit comments

Comments
 (0)