@graphitation/supermassive 2.5.0 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -1
- package/CHANGELOG.md +18 -2
- package/lib/benchmarks/index.js +2 -2
- package/lib/benchmarks/index.js.map +2 -2
- package/lib/benchmarks/index.mjs +2 -2
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/index.d.ts +4 -2
- package/lib/benchmarks/swapi-schema/index.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/index.js +8 -2
- package/lib/benchmarks/swapi-schema/index.js.map +2 -2
- package/lib/benchmarks/swapi-schema/index.mjs +8 -2
- package/lib/benchmarks/swapi-schema/index.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts +7 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts.map +1 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js +916 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js.map +7 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs +903 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs.map +7 -0
- package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +53 -17
- package/lib/benchmarks/swapi-schema/resolvers.js.map +2 -2
- package/lib/benchmarks/swapi-schema/resolvers.mjs +54 -18
- package/lib/benchmarks/swapi-schema/resolvers.mjs.map +2 -2
- package/lib/collectFields.d.ts +28 -6
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +155 -28
- package/lib/collectFields.js.map +3 -3
- package/lib/collectFields.mjs +150 -29
- package/lib/collectFields.mjs.map +2 -2
- package/lib/definition.js +1 -1
- package/lib/definition.js.map +2 -2
- package/lib/definition.mjs +1 -1
- package/lib/definition.mjs.map +2 -2
- package/lib/directives.d.ts +2 -73
- package/lib/directives.d.ts.map +1 -1
- package/lib/directives.js +10 -123
- package/lib/directives.js.map +2 -2
- package/lib/directives.mjs +13 -122
- package/lib/directives.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +50 -13
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +1038 -184
- package/lib/executeWithoutSchema.js.map +3 -3
- package/lib/executeWithoutSchema.mjs +1049 -186
- package/lib/executeWithoutSchema.mjs.map +3 -3
- package/lib/extractImplicitTypesRuntime.js +2 -2
- package/lib/extractImplicitTypesRuntime.js.map +2 -2
- package/lib/extractImplicitTypesRuntime.mjs +2 -2
- package/lib/extractImplicitTypesRuntime.mjs.map +2 -2
- package/lib/hooks/types.d.ts +1 -1
- package/lib/hooks/types.d.ts.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +4 -1
- package/lib/index.mjs.map +2 -2
- package/lib/jsutils/AccumulatorMap.d.ts +8 -0
- package/lib/jsutils/AccumulatorMap.d.ts.map +1 -0
- package/lib/jsutils/AccumulatorMap.js +36 -0
- package/lib/jsutils/AccumulatorMap.js.map +7 -0
- package/lib/jsutils/AccumulatorMap.mjs +17 -0
- package/lib/jsutils/AccumulatorMap.mjs.map +7 -0
- package/lib/jsutils/Maybe.d.ts +1 -1
- package/lib/jsutils/Maybe.d.ts.map +1 -1
- package/lib/jsutils/ObjMap.d.ts +2 -2
- package/lib/jsutils/ObjMap.d.ts.map +1 -1
- package/lib/jsutils/PromiseOrValue.d.ts +1 -1
- package/lib/jsutils/PromiseOrValue.d.ts.map +1 -1
- package/lib/jsutils/didYouMean.d.ts +1 -2
- package/lib/jsutils/didYouMean.d.ts.map +1 -1
- package/lib/jsutils/didYouMean.js.map +2 -2
- package/lib/jsutils/didYouMean.mjs.map +2 -2
- package/lib/jsutils/instanceOf.js.map +2 -2
- package/lib/jsutils/instanceOf.mjs.map +2 -2
- package/lib/subscribeWithSchema.d.ts +3 -2
- package/lib/subscribeWithSchema.d.ts.map +1 -1
- package/lib/subscribeWithSchema.js.map +2 -2
- package/lib/subscribeWithSchema.mjs.map +2 -2
- package/lib/subscribeWithoutSchema.d.ts +3 -35
- package/lib/subscribeWithoutSchema.d.ts.map +1 -1
- package/lib/subscribeWithoutSchema.js +1 -163
- package/lib/subscribeWithoutSchema.js.map +2 -2
- package/lib/subscribeWithoutSchema.mjs +2 -175
- package/lib/subscribeWithoutSchema.mjs.map +2 -2
- package/lib/supermassive-ast/TypedAST.d.ts +370 -0
- package/lib/supermassive-ast/TypedAST.d.ts.map +1 -0
- package/lib/supermassive-ast/TypedAST.js +29 -0
- package/lib/supermassive-ast/TypedAST.js.map +7 -0
- package/lib/supermassive-ast/TypedAST.mjs +10 -0
- package/lib/supermassive-ast/TypedAST.mjs.map +7 -0
- package/lib/supermassive-ast/addTypesToRequestDocument.d.ts +56 -0
- package/lib/supermassive-ast/addTypesToRequestDocument.d.ts.map +1 -0
- package/lib/supermassive-ast/addTypesToRequestDocument.js +473 -0
- package/lib/supermassive-ast/addTypesToRequestDocument.js.map +7 -0
- package/lib/supermassive-ast/addTypesToRequestDocument.mjs +463 -0
- package/lib/supermassive-ast/addTypesToRequestDocument.mjs.map +7 -0
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.d.ts +3 -0
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.js +34 -0
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.js.map +7 -0
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.mjs +17 -0
- package/lib/supermassive-ast/annotateDocumentGraphQLTransform.mjs.map +7 -0
- package/lib/supermassive-ast/directives.d.ts +36 -0
- package/lib/supermassive-ast/directives.d.ts.map +1 -0
- package/lib/supermassive-ast/directives.js +165 -0
- package/lib/supermassive-ast/directives.js.map +7 -0
- package/lib/supermassive-ast/directives.mjs +153 -0
- package/lib/supermassive-ast/directives.mjs.map +7 -0
- package/lib/supermassive-ast/index.d.ts +6 -0
- package/lib/supermassive-ast/index.d.ts.map +1 -0
- package/lib/supermassive-ast/index.js +37 -0
- package/lib/supermassive-ast/index.js.map +7 -0
- package/lib/supermassive-ast/index.mjs +27 -0
- package/lib/supermassive-ast/index.mjs.map +7 -0
- package/lib/types.d.ts +80 -24
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +14 -0
- package/lib/types.js.map +2 -2
- package/lib/types.mjs +11 -0
- package/lib/types.mjs.map +3 -3
- package/lib/utilities/mergeResolvers.d.ts +1 -1
- package/lib/utilities/mergeResolvers.d.ts.map +1 -1
- package/lib/utilities/mergeResolvers.js.map +2 -2
- package/lib/utilities/mergeResolvers.mjs.map +2 -2
- package/lib/utilities/typeNameFromAST.d.ts +1 -1
- package/lib/utilities/typeNameFromAST.d.ts.map +1 -1
- package/lib/utilities/typeNameFromAST.js.map +1 -1
- package/lib/utilities/typeNameFromAST.mjs.map +1 -1
- package/lib/values.d.ts +3 -4
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +10 -14
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +10 -14
- package/lib/values.mjs.map +2 -2
- package/package.json +4 -9
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
6
23
|
var __export = (target, all) => {
|
|
7
24
|
for (var name in all)
|
|
8
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,10 +33,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
33
|
return to;
|
|
17
34
|
};
|
|
18
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
var __async = (__this, __arguments, generator) => {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
var fulfilled = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.next(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var rejected = (value) => {
|
|
46
|
+
try {
|
|
47
|
+
step(generator.throw(value));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
53
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
19
56
|
var executeWithoutSchema_exports = {};
|
|
20
57
|
__export(executeWithoutSchema_exports, {
|
|
21
58
|
assertValidExecutionArguments: () => assertValidExecutionArguments,
|
|
22
|
-
buildExecutionContext: () => buildExecutionContext,
|
|
23
59
|
buildResolveInfo: () => buildResolveInfo,
|
|
24
60
|
defaultFieldResolver: () => defaultFieldResolver,
|
|
25
61
|
defaultTypeResolver: () => defaultTypeResolver,
|
|
@@ -28,6 +64,7 @@ __export(executeWithoutSchema_exports, {
|
|
|
28
64
|
});
|
|
29
65
|
module.exports = __toCommonJS(executeWithoutSchema_exports);
|
|
30
66
|
var import_graphql = require("graphql");
|
|
67
|
+
var import_supermassive_ast = require("./supermassive-ast");
|
|
31
68
|
var import_collectFields = require("./collectFields");
|
|
32
69
|
var import_devAssert = require("./jsutils/devAssert");
|
|
33
70
|
var import_inspect = require("./jsutils/inspect");
|
|
@@ -43,47 +80,28 @@ var import_mergeResolvers = require("./utilities/mergeResolvers");
|
|
|
43
80
|
var import_typeNameFromAST = require("./utilities/typeNameFromAST");
|
|
44
81
|
var import_values = require("./values");
|
|
45
82
|
var import_array = require("./utilities/array");
|
|
83
|
+
var import_isAsyncIterable = require("./jsutils/isAsyncIterable");
|
|
84
|
+
var import_mapAsyncIterator = require("./utilities/mapAsyncIterator");
|
|
85
|
+
var import_directives = require("./directives");
|
|
86
|
+
var import_memoize3 = require("./jsutils/memoize3");
|
|
87
|
+
const collectSubfields = (0, import_memoize3.memoize3)(
|
|
88
|
+
(exeContext, returnTypeName, fieldGroup) => (0, import_collectFields.collectSubfields)(
|
|
89
|
+
exeContext.resolvers,
|
|
90
|
+
exeContext.fragments,
|
|
91
|
+
exeContext.variableValues,
|
|
92
|
+
exeContext.operation,
|
|
93
|
+
returnTypeName.name,
|
|
94
|
+
fieldGroup
|
|
95
|
+
)
|
|
96
|
+
);
|
|
46
97
|
function executeWithoutSchema(args) {
|
|
47
|
-
const
|
|
48
|
-
resolvers,
|
|
49
|
-
schemaResolvers,
|
|
50
|
-
document,
|
|
51
|
-
rootValue,
|
|
52
|
-
contextValue,
|
|
53
|
-
variableValues,
|
|
54
|
-
operationName,
|
|
55
|
-
fieldResolver,
|
|
56
|
-
typeResolver,
|
|
57
|
-
fieldExecutionHooks
|
|
58
|
-
} = args;
|
|
59
|
-
const combinedResolvers = schemaResolvers ? (0, import_mergeResolvers.mergeResolvers)(resolvers, schemaResolvers) : resolvers;
|
|
60
|
-
assertValidExecutionArguments(document, variableValues);
|
|
61
|
-
const exeContext = buildExecutionContext(
|
|
62
|
-
combinedResolvers,
|
|
63
|
-
document,
|
|
64
|
-
rootValue,
|
|
65
|
-
contextValue,
|
|
66
|
-
variableValues,
|
|
67
|
-
operationName,
|
|
68
|
-
fieldResolver,
|
|
69
|
-
typeResolver,
|
|
70
|
-
fieldExecutionHooks
|
|
71
|
-
);
|
|
98
|
+
const exeContext = buildExecutionContext(args);
|
|
72
99
|
if (!("resolvers" in exeContext)) {
|
|
73
100
|
return { errors: exeContext };
|
|
74
101
|
} else {
|
|
75
|
-
|
|
76
|
-
return buildResponse(exeContext, data);
|
|
102
|
+
return executeOperation(exeContext);
|
|
77
103
|
}
|
|
78
104
|
}
|
|
79
|
-
function buildResponse(exeContext, data) {
|
|
80
|
-
if ((0, import_isPromise.isPromise)(data)) {
|
|
81
|
-
return data.then(
|
|
82
|
-
(resolved) => buildResponse(exeContext, resolved)
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
86
|
-
}
|
|
87
105
|
function assertValidExecutionArguments(document, rawVariableValues) {
|
|
88
106
|
(0, import_devAssert.devAssert)(document, "Must provide document.");
|
|
89
107
|
(0, import_devAssert.devAssert)(
|
|
@@ -91,8 +109,24 @@ function assertValidExecutionArguments(document, rawVariableValues) {
|
|
|
91
109
|
"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided."
|
|
92
110
|
);
|
|
93
111
|
}
|
|
94
|
-
function buildExecutionContext(
|
|
112
|
+
function buildExecutionContext(args) {
|
|
95
113
|
var _a, _b;
|
|
114
|
+
const {
|
|
115
|
+
resolvers,
|
|
116
|
+
schemaResolvers,
|
|
117
|
+
document,
|
|
118
|
+
rootValue,
|
|
119
|
+
contextValue,
|
|
120
|
+
buildContextValue,
|
|
121
|
+
variableValues,
|
|
122
|
+
operationName,
|
|
123
|
+
fieldResolver,
|
|
124
|
+
typeResolver,
|
|
125
|
+
subscribeFieldResolver,
|
|
126
|
+
fieldExecutionHooks
|
|
127
|
+
} = args;
|
|
128
|
+
assertValidExecutionArguments(document, variableValues);
|
|
129
|
+
const combinedResolvers = schemaResolvers ? (0, import_mergeResolvers.mergeResolvers)(resolvers, schemaResolvers) : resolvers;
|
|
96
130
|
let operation;
|
|
97
131
|
const fragments = /* @__PURE__ */ Object.create(null);
|
|
98
132
|
for (const definition of document.definitions) {
|
|
@@ -124,64 +158,135 @@ function buildExecutionContext(resolvers, document, rootValue, contextValue, raw
|
|
|
124
158
|
}
|
|
125
159
|
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : [];
|
|
126
160
|
const coercedVariableValues = (0, import_values.getVariableValues)(
|
|
127
|
-
|
|
161
|
+
combinedResolvers,
|
|
128
162
|
variableDefinitions,
|
|
129
|
-
|
|
163
|
+
variableValues != null ? variableValues : {},
|
|
130
164
|
{ maxErrors: 50 }
|
|
131
165
|
);
|
|
132
166
|
if (coercedVariableValues.errors) {
|
|
133
167
|
return coercedVariableValues.errors;
|
|
134
168
|
}
|
|
135
169
|
return {
|
|
136
|
-
resolvers,
|
|
170
|
+
resolvers: combinedResolvers,
|
|
137
171
|
fragments,
|
|
138
172
|
rootValue,
|
|
139
|
-
contextValue,
|
|
173
|
+
contextValue: buildContextValue ? buildContextValue(contextValue) : contextValue,
|
|
174
|
+
buildContextValue,
|
|
140
175
|
operation,
|
|
141
176
|
variableValues: coercedVariableValues.coerced,
|
|
142
177
|
fieldResolver: fieldResolver != null ? fieldResolver : defaultFieldResolver,
|
|
143
178
|
typeResolver: typeResolver != null ? typeResolver : defaultTypeResolver,
|
|
179
|
+
subscribeFieldResolver: subscribeFieldResolver != null ? subscribeFieldResolver : defaultFieldResolver,
|
|
144
180
|
errors: [],
|
|
145
|
-
fieldExecutionHooks
|
|
181
|
+
fieldExecutionHooks,
|
|
182
|
+
subsequentPayloads: /* @__PURE__ */ new Set()
|
|
146
183
|
};
|
|
147
184
|
}
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
185
|
+
function buildPerEventExecutionContext(exeContext, payload) {
|
|
186
|
+
return __spreadProps(__spreadValues({}, exeContext), {
|
|
187
|
+
contextValue: exeContext.buildContextValue ? exeContext.buildContextValue(exeContext.contextValue) : exeContext.contextValue,
|
|
188
|
+
rootValue: payload,
|
|
189
|
+
subsequentPayloads: /* @__PURE__ */ new Set(),
|
|
190
|
+
errors: []
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function executeOperation(exeContext) {
|
|
194
|
+
const { operation, rootValue, resolvers, fragments, variableValues } = exeContext;
|
|
195
|
+
const rootTypeName = getOperationRootTypeName(operation);
|
|
196
|
+
const { groupedFieldSet, patches } = (0, import_collectFields.collectFields)(
|
|
197
|
+
resolvers,
|
|
198
|
+
fragments,
|
|
199
|
+
variableValues,
|
|
200
|
+
rootTypeName,
|
|
201
|
+
operation
|
|
158
202
|
);
|
|
159
203
|
const path = void 0;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
204
|
+
let result;
|
|
205
|
+
switch (operation.operation) {
|
|
206
|
+
case import_supermassive_ast.OperationTypeNode.QUERY:
|
|
207
|
+
result = executeFields(
|
|
208
|
+
exeContext,
|
|
209
|
+
rootTypeName,
|
|
210
|
+
rootValue,
|
|
211
|
+
path,
|
|
212
|
+
groupedFieldSet,
|
|
213
|
+
void 0
|
|
214
|
+
);
|
|
215
|
+
result = buildResponse(exeContext, result);
|
|
216
|
+
break;
|
|
217
|
+
case import_supermassive_ast.OperationTypeNode.MUTATION:
|
|
218
|
+
result = executeFieldsSerially(
|
|
219
|
+
exeContext,
|
|
220
|
+
rootTypeName,
|
|
221
|
+
rootValue,
|
|
222
|
+
path,
|
|
223
|
+
groupedFieldSet
|
|
224
|
+
);
|
|
225
|
+
result = buildResponse(exeContext, result);
|
|
226
|
+
break;
|
|
227
|
+
case import_supermassive_ast.OperationTypeNode.SUBSCRIPTION: {
|
|
228
|
+
const resultOrStreamOrPromise = createSourceEventStream(exeContext);
|
|
229
|
+
result = mapResultOrEventStreamOrPromise(
|
|
230
|
+
resultOrStreamOrPromise,
|
|
231
|
+
exeContext,
|
|
232
|
+
rootTypeName,
|
|
233
|
+
path,
|
|
234
|
+
groupedFieldSet
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
for (const patch of patches) {
|
|
239
|
+
const { label, groupedFieldSet: patchGroupedFieldSet } = patch;
|
|
240
|
+
executeDeferredFragment(
|
|
241
|
+
exeContext,
|
|
242
|
+
rootTypeName,
|
|
243
|
+
rootValue,
|
|
244
|
+
patchGroupedFieldSet,
|
|
245
|
+
label,
|
|
246
|
+
path
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
function buildResponse(exeContext, data) {
|
|
252
|
+
if ((0, import_isPromise.isPromise)(data)) {
|
|
253
|
+
return data.then(
|
|
254
|
+
(resolved) => buildResponse(exeContext, resolved),
|
|
255
|
+
(error) => {
|
|
164
256
|
exeContext.errors.push(error);
|
|
165
|
-
return
|
|
166
|
-
}
|
|
257
|
+
return buildResponse(exeContext, null);
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
try {
|
|
262
|
+
const initialResult = exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
263
|
+
if (exeContext.subsequentPayloads.size > 0) {
|
|
264
|
+
return {
|
|
265
|
+
initialResult: __spreadProps(__spreadValues({}, initialResult), {
|
|
266
|
+
hasNext: true
|
|
267
|
+
}),
|
|
268
|
+
subsequentResults: yieldSubsequentPayloads(exeContext)
|
|
269
|
+
};
|
|
270
|
+
} else {
|
|
271
|
+
return initialResult;
|
|
167
272
|
}
|
|
168
|
-
return result;
|
|
169
273
|
} catch (error) {
|
|
170
274
|
exeContext.errors.push(error);
|
|
171
|
-
return null;
|
|
275
|
+
return buildResponse(exeContext, null);
|
|
172
276
|
}
|
|
173
277
|
}
|
|
174
|
-
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path,
|
|
278
|
+
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, groupedFieldSet) {
|
|
175
279
|
return (0, import_promiseReduce.promiseReduce)(
|
|
176
|
-
|
|
177
|
-
(results, [responseName,
|
|
280
|
+
groupedFieldSet,
|
|
281
|
+
(results, [responseName, fieldGroup]) => {
|
|
178
282
|
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
179
283
|
const result = executeField(
|
|
180
284
|
exeContext,
|
|
181
285
|
parentTypeName,
|
|
182
286
|
sourceValue,
|
|
183
|
-
|
|
184
|
-
fieldPath
|
|
287
|
+
fieldGroup,
|
|
288
|
+
fieldPath,
|
|
289
|
+
void 0
|
|
185
290
|
);
|
|
186
291
|
if (result === void 0) {
|
|
187
292
|
return results;
|
|
@@ -198,17 +303,18 @@ function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, fi
|
|
|
198
303
|
/* @__PURE__ */ Object.create(null)
|
|
199
304
|
);
|
|
200
305
|
}
|
|
201
|
-
function executeFields(exeContext, parentTypeName, sourceValue, path,
|
|
306
|
+
function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFieldSet, incrementalDataRecord) {
|
|
202
307
|
const results = /* @__PURE__ */ Object.create(null);
|
|
203
308
|
let containsPromise = false;
|
|
204
|
-
for (const [responseName,
|
|
309
|
+
for (const [responseName, fieldGroup] of groupedFieldSet) {
|
|
205
310
|
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
206
311
|
const result = executeField(
|
|
207
312
|
exeContext,
|
|
208
313
|
parentTypeName,
|
|
209
314
|
sourceValue,
|
|
210
|
-
|
|
211
|
-
fieldPath
|
|
315
|
+
fieldGroup,
|
|
316
|
+
fieldPath,
|
|
317
|
+
incrementalDataRecord
|
|
212
318
|
);
|
|
213
319
|
if (result !== void 0) {
|
|
214
320
|
results[responseName] = result;
|
|
@@ -222,9 +328,8 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, fields) {
|
|
|
222
328
|
}
|
|
223
329
|
return (0, import_promiseForObject.promiseForObject)(results);
|
|
224
330
|
}
|
|
225
|
-
function executeField(exeContext, parentTypeName, source,
|
|
226
|
-
const fieldName =
|
|
227
|
-
const hooks = exeContext.fieldExecutionHooks;
|
|
331
|
+
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord) {
|
|
332
|
+
const fieldName = fieldGroup[0].name.value;
|
|
228
333
|
let resolveFn;
|
|
229
334
|
let returnTypeName;
|
|
230
335
|
let returnTypeNode;
|
|
@@ -239,7 +344,7 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
239
344
|
}
|
|
240
345
|
};
|
|
241
346
|
} else {
|
|
242
|
-
returnTypeNode =
|
|
347
|
+
returnTypeNode = fieldGroup[0].__type;
|
|
243
348
|
returnTypeName = (0, import_typeNameFromAST.typeNameFromAST)(returnTypeNode);
|
|
244
349
|
const typeResolvers = exeContext.resolvers[parentTypeName];
|
|
245
350
|
resolveFn = typeResolvers == null ? void 0 : typeResolvers[fieldName];
|
|
@@ -254,22 +359,187 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
254
359
|
const info = buildResolveInfo(
|
|
255
360
|
exeContext,
|
|
256
361
|
fieldName,
|
|
257
|
-
|
|
362
|
+
fieldGroup,
|
|
258
363
|
parentTypeName,
|
|
259
364
|
returnTypeName,
|
|
260
365
|
returnTypeNode,
|
|
261
366
|
path
|
|
262
367
|
);
|
|
368
|
+
return resolveAndCompleteField(
|
|
369
|
+
exeContext,
|
|
370
|
+
returnTypeNode,
|
|
371
|
+
fieldGroup,
|
|
372
|
+
info,
|
|
373
|
+
path,
|
|
374
|
+
resolveFn,
|
|
375
|
+
source,
|
|
376
|
+
incrementalDataRecord,
|
|
377
|
+
isDefaultResolverUsed
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
function createSourceEventStream(exeContext) {
|
|
381
|
+
try {
|
|
382
|
+
const eventStream = executeSubscriptionImpl(exeContext);
|
|
383
|
+
if ((0, import_isPromise.isPromise)(eventStream)) {
|
|
384
|
+
return eventStream.then(void 0, (error) => ({ errors: [error] }));
|
|
385
|
+
}
|
|
386
|
+
return eventStream;
|
|
387
|
+
} catch (error) {
|
|
388
|
+
return { errors: [error] };
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function executeSubscriptionImpl(exeContext) {
|
|
392
|
+
const { resolvers, fragments, operation, variableValues, rootValue } = exeContext;
|
|
393
|
+
const typeName = getOperationRootTypeName(operation);
|
|
394
|
+
const { groupedFieldSet } = (0, import_collectFields.collectFields)(
|
|
395
|
+
resolvers,
|
|
396
|
+
fragments,
|
|
397
|
+
variableValues,
|
|
398
|
+
typeName,
|
|
399
|
+
operation
|
|
400
|
+
);
|
|
401
|
+
const firstRootField = groupedFieldSet.entries().next().value;
|
|
402
|
+
const [responseName, fieldGroup] = firstRootField;
|
|
403
|
+
const fieldName = fieldGroup[0].name.value;
|
|
404
|
+
let resolveFn;
|
|
405
|
+
let returnTypeName;
|
|
406
|
+
let returnTypeNode;
|
|
407
|
+
if (fieldName === "__typename" && !resolveFn) {
|
|
408
|
+
resolveFn = () => typeName;
|
|
409
|
+
returnTypeName = "String";
|
|
410
|
+
returnTypeNode = {
|
|
411
|
+
kind: import_graphql.Kind.NAMED_TYPE,
|
|
412
|
+
name: {
|
|
413
|
+
kind: import_graphql.Kind.NAME,
|
|
414
|
+
value: "String"
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
} else {
|
|
418
|
+
returnTypeNode = fieldGroup[0].__type;
|
|
419
|
+
returnTypeName = (0, import_typeNameFromAST.typeNameFromAST)(returnTypeNode);
|
|
420
|
+
const typeResolvers = exeContext.resolvers[typeName];
|
|
421
|
+
const fieldResolver = typeResolvers == null ? void 0 : typeResolvers[fieldName];
|
|
422
|
+
resolveFn = fieldResolver == null ? void 0 : fieldResolver.subscribe;
|
|
423
|
+
}
|
|
424
|
+
if (!resolveFn) {
|
|
425
|
+
resolveFn = exeContext.subscribeFieldResolver;
|
|
426
|
+
}
|
|
427
|
+
const path = (0, import_Path.addPath)(void 0, responseName, typeName);
|
|
428
|
+
const info = buildResolveInfo(
|
|
429
|
+
exeContext,
|
|
430
|
+
fieldName,
|
|
431
|
+
fieldGroup,
|
|
432
|
+
typeName,
|
|
433
|
+
returnTypeName,
|
|
434
|
+
returnTypeNode,
|
|
435
|
+
path
|
|
436
|
+
);
|
|
437
|
+
try {
|
|
438
|
+
const args = (0, import_values.getArgumentValues)(resolvers, fieldGroup[0], variableValues);
|
|
439
|
+
const contextValue = exeContext.contextValue;
|
|
440
|
+
const result = resolveFn(rootValue, args, contextValue, info);
|
|
441
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
442
|
+
return result.then(assertEventStream).then(void 0, (error) => {
|
|
443
|
+
throw (0, import_graphql.locatedError)(
|
|
444
|
+
error,
|
|
445
|
+
fieldGroup,
|
|
446
|
+
(0, import_Path.pathToArray)(path)
|
|
447
|
+
);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
return assertEventStream(result);
|
|
451
|
+
} catch (error) {
|
|
452
|
+
throw (0, import_graphql.locatedError)(
|
|
453
|
+
error,
|
|
454
|
+
fieldGroup,
|
|
455
|
+
(0, import_Path.pathToArray)(path)
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function assertEventStream(result) {
|
|
460
|
+
if (result instanceof Error) {
|
|
461
|
+
throw result;
|
|
462
|
+
}
|
|
463
|
+
if (!(0, import_isAsyncIterable.isAsyncIterable)(result)) {
|
|
464
|
+
throw new import_graphql.GraphQLError(
|
|
465
|
+
`Subscription field must return Async Iterable. Received: ${(0, import_inspect.inspect)(result)}.`
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
return result;
|
|
469
|
+
}
|
|
470
|
+
function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, parentTypeName, path, groupedFieldSet) {
|
|
471
|
+
if ((0, import_isPromise.isPromise)(resultOrStreamOrPromise)) {
|
|
472
|
+
return resultOrStreamOrPromise.then(
|
|
473
|
+
(resultOrStream) => mapResultOrEventStreamOrPromise(
|
|
474
|
+
resultOrStream,
|
|
475
|
+
exeContext,
|
|
476
|
+
parentTypeName,
|
|
477
|
+
path,
|
|
478
|
+
groupedFieldSet
|
|
479
|
+
)
|
|
480
|
+
);
|
|
481
|
+
} else {
|
|
482
|
+
if (!(0, import_isAsyncIterable.isAsyncIterable)(resultOrStreamOrPromise)) {
|
|
483
|
+
return resultOrStreamOrPromise;
|
|
484
|
+
} else {
|
|
485
|
+
const mapSourceToResponse = (payload) => {
|
|
486
|
+
const perEventContext = buildPerEventExecutionContext(
|
|
487
|
+
exeContext,
|
|
488
|
+
payload
|
|
489
|
+
);
|
|
490
|
+
const data = executeFields(
|
|
491
|
+
exeContext,
|
|
492
|
+
parentTypeName,
|
|
493
|
+
payload,
|
|
494
|
+
path,
|
|
495
|
+
groupedFieldSet,
|
|
496
|
+
void 0
|
|
497
|
+
);
|
|
498
|
+
return buildResponse(perEventContext, data);
|
|
499
|
+
};
|
|
500
|
+
return (0, import_mapAsyncIterator.mapAsyncIterator)(resultOrStreamOrPromise, mapSourceToResponse);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, returnTypeName, returnTypeNode, path) {
|
|
505
|
+
return {
|
|
506
|
+
fieldName,
|
|
507
|
+
fieldGroup,
|
|
508
|
+
returnTypeName,
|
|
509
|
+
parentTypeName,
|
|
510
|
+
returnTypeNode,
|
|
511
|
+
path,
|
|
512
|
+
fragments: exeContext.fragments,
|
|
513
|
+
rootValue: exeContext.rootValue,
|
|
514
|
+
operation: exeContext.operation,
|
|
515
|
+
variableValues: exeContext.variableValues
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
function handleFieldError(rawError, exeContext, returnTypeNode, fieldGroup, path, incrementalDataRecord) {
|
|
519
|
+
var _a;
|
|
520
|
+
const error = (0, import_graphql.locatedError)(
|
|
521
|
+
rawError,
|
|
522
|
+
fieldGroup,
|
|
523
|
+
(0, import_Path.pathToArray)(path)
|
|
524
|
+
);
|
|
525
|
+
if (returnTypeNode.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
526
|
+
throw error;
|
|
527
|
+
}
|
|
528
|
+
const errors = (_a = incrementalDataRecord == null ? void 0 : incrementalDataRecord.errors) != null ? _a : exeContext.errors;
|
|
529
|
+
errors.push(error);
|
|
530
|
+
}
|
|
531
|
+
function resolveAndCompleteField(exeContext, returnTypeNode, fieldGroup, info, path, resolveFn, source, incrementalDataRecord, isDefaultResolverUsed) {
|
|
532
|
+
const hooks = exeContext.fieldExecutionHooks;
|
|
263
533
|
try {
|
|
264
534
|
const args = (0, import_values.getArgumentValues)(
|
|
265
535
|
exeContext.resolvers,
|
|
266
|
-
|
|
536
|
+
fieldGroup[0],
|
|
267
537
|
exeContext.variableValues
|
|
268
538
|
);
|
|
539
|
+
const contextValue = exeContext.contextValue;
|
|
269
540
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldResolve)) {
|
|
270
541
|
invokeBeforeFieldResolveHook(info, exeContext);
|
|
271
542
|
}
|
|
272
|
-
const contextValue = exeContext.contextValue;
|
|
273
543
|
const result = resolveFn(source, args, contextValue, info);
|
|
274
544
|
let completed;
|
|
275
545
|
if ((0, import_isPromise.isPromise)(result)) {
|
|
@@ -281,10 +551,11 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
281
551
|
return completeValue(
|
|
282
552
|
exeContext,
|
|
283
553
|
returnTypeNode,
|
|
284
|
-
|
|
554
|
+
fieldGroup,
|
|
285
555
|
info,
|
|
286
556
|
path,
|
|
287
|
-
resolved
|
|
557
|
+
resolved,
|
|
558
|
+
incrementalDataRecord
|
|
288
559
|
);
|
|
289
560
|
},
|
|
290
561
|
(rawError) => {
|
|
@@ -301,10 +572,11 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
301
572
|
completed = completeValue(
|
|
302
573
|
exeContext,
|
|
303
574
|
returnTypeNode,
|
|
304
|
-
|
|
575
|
+
fieldGroup,
|
|
305
576
|
info,
|
|
306
577
|
path,
|
|
307
|
-
result
|
|
578
|
+
result,
|
|
579
|
+
incrementalDataRecord
|
|
308
580
|
);
|
|
309
581
|
}
|
|
310
582
|
if ((0, import_isPromise.isPromise)(completed)) {
|
|
@@ -318,13 +590,21 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
318
590
|
(rawError) => {
|
|
319
591
|
const error = (0, import_graphql.locatedError)(
|
|
320
592
|
rawError,
|
|
321
|
-
|
|
593
|
+
fieldGroup,
|
|
322
594
|
(0, import_Path.pathToArray)(path)
|
|
323
595
|
);
|
|
324
596
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
325
597
|
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
|
|
326
598
|
}
|
|
327
|
-
|
|
599
|
+
handleFieldError(
|
|
600
|
+
rawError,
|
|
601
|
+
exeContext,
|
|
602
|
+
returnTypeNode,
|
|
603
|
+
fieldGroup,
|
|
604
|
+
path,
|
|
605
|
+
incrementalDataRecord
|
|
606
|
+
);
|
|
607
|
+
return null;
|
|
328
608
|
}
|
|
329
609
|
);
|
|
330
610
|
}
|
|
@@ -336,7 +616,7 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
336
616
|
const pathArray = (0, import_Path.pathToArray)(path);
|
|
337
617
|
const error = (0, import_graphql.locatedError)(
|
|
338
618
|
rawError,
|
|
339
|
-
|
|
619
|
+
fieldGroup,
|
|
340
620
|
pathArray
|
|
341
621
|
);
|
|
342
622
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve) && error.path && (0, import_array.arraysAreEqual)(pathArray, error.path)) {
|
|
@@ -345,31 +625,18 @@ function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
|
345
625
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
346
626
|
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
|
|
347
627
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
returnTypeNode,
|
|
358
|
-
path,
|
|
359
|
-
fragments: exeContext.fragments,
|
|
360
|
-
rootValue: exeContext.rootValue,
|
|
361
|
-
operation: exeContext.operation,
|
|
362
|
-
variableValues: exeContext.variableValues
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
function handleFieldError(error, returnTypeNode, exeContext) {
|
|
366
|
-
if (returnTypeNode.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
367
|
-
throw error;
|
|
628
|
+
handleFieldError(
|
|
629
|
+
rawError,
|
|
630
|
+
exeContext,
|
|
631
|
+
returnTypeNode,
|
|
632
|
+
fieldGroup,
|
|
633
|
+
path,
|
|
634
|
+
incrementalDataRecord
|
|
635
|
+
);
|
|
636
|
+
return null;
|
|
368
637
|
}
|
|
369
|
-
exeContext.errors.push(error);
|
|
370
|
-
return null;
|
|
371
638
|
}
|
|
372
|
-
function completeValue(exeContext, returnTypeNode,
|
|
639
|
+
function completeValue(exeContext, returnTypeNode, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
373
640
|
if (result instanceof Error) {
|
|
374
641
|
throw result;
|
|
375
642
|
}
|
|
@@ -377,10 +644,11 @@ function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resul
|
|
|
377
644
|
const completed = completeValue(
|
|
378
645
|
exeContext,
|
|
379
646
|
returnTypeNode.type,
|
|
380
|
-
|
|
647
|
+
fieldGroup,
|
|
381
648
|
info,
|
|
382
649
|
path,
|
|
383
|
-
result
|
|
650
|
+
result,
|
|
651
|
+
incrementalDataRecord
|
|
384
652
|
);
|
|
385
653
|
if (completed === null) {
|
|
386
654
|
throw new Error(
|
|
@@ -395,11 +663,12 @@ function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resul
|
|
|
395
663
|
if (returnTypeNode.kind === import_graphql.Kind.LIST_TYPE) {
|
|
396
664
|
return completeListValue(
|
|
397
665
|
exeContext,
|
|
398
|
-
returnTypeNode
|
|
399
|
-
|
|
666
|
+
returnTypeNode,
|
|
667
|
+
fieldGroup,
|
|
400
668
|
info,
|
|
401
669
|
path,
|
|
402
|
-
result
|
|
670
|
+
result,
|
|
671
|
+
incrementalDataRecord
|
|
403
672
|
);
|
|
404
673
|
}
|
|
405
674
|
const returnTypeName = returnTypeNode.name.value;
|
|
@@ -416,20 +685,21 @@ function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resul
|
|
|
416
685
|
return completeAbstractValue(
|
|
417
686
|
exeContext,
|
|
418
687
|
returnType,
|
|
419
|
-
|
|
688
|
+
fieldGroup,
|
|
420
689
|
info,
|
|
421
690
|
path,
|
|
422
|
-
result
|
|
691
|
+
result,
|
|
692
|
+
incrementalDataRecord
|
|
423
693
|
);
|
|
424
694
|
}
|
|
425
695
|
if (typeof returnType === "object") {
|
|
426
696
|
return completeObjectValue(
|
|
427
697
|
exeContext,
|
|
428
698
|
returnTypeName,
|
|
429
|
-
|
|
430
|
-
info,
|
|
699
|
+
fieldGroup,
|
|
431
700
|
path,
|
|
432
|
-
result
|
|
701
|
+
result,
|
|
702
|
+
incrementalDataRecord
|
|
433
703
|
);
|
|
434
704
|
}
|
|
435
705
|
(0, import_invariant.invariant)(
|
|
@@ -437,60 +707,235 @@ function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resul
|
|
|
437
707
|
"Cannot complete value of unexpected output type: " + (0, import_inspect.inspect)(returnType)
|
|
438
708
|
);
|
|
439
709
|
}
|
|
440
|
-
function
|
|
710
|
+
function completePromisedValue(exeContext, returnTypeNode, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
711
|
+
return __async(this, null, function* () {
|
|
712
|
+
try {
|
|
713
|
+
const resolved = yield result;
|
|
714
|
+
let completed = completeValue(
|
|
715
|
+
exeContext,
|
|
716
|
+
returnTypeNode,
|
|
717
|
+
fieldGroup,
|
|
718
|
+
info,
|
|
719
|
+
path,
|
|
720
|
+
resolved,
|
|
721
|
+
incrementalDataRecord
|
|
722
|
+
);
|
|
723
|
+
if ((0, import_isPromise.isPromise)(completed)) {
|
|
724
|
+
completed = yield completed;
|
|
725
|
+
}
|
|
726
|
+
return completed;
|
|
727
|
+
} catch (rawError) {
|
|
728
|
+
handleFieldError(
|
|
729
|
+
rawError,
|
|
730
|
+
exeContext,
|
|
731
|
+
returnTypeNode,
|
|
732
|
+
fieldGroup,
|
|
733
|
+
path,
|
|
734
|
+
incrementalDataRecord
|
|
735
|
+
);
|
|
736
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
function completeListValue(exeContext, returnTypeNode, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
742
|
+
const itemType = returnTypeNode.type;
|
|
743
|
+
if ((0, import_isAsyncIterable.isAsyncIterable)(result)) {
|
|
744
|
+
const asyncIterator = result[Symbol.asyncIterator]();
|
|
745
|
+
return completeAsyncIteratorValue(
|
|
746
|
+
exeContext,
|
|
747
|
+
itemType,
|
|
748
|
+
fieldGroup,
|
|
749
|
+
info,
|
|
750
|
+
path,
|
|
751
|
+
asyncIterator,
|
|
752
|
+
incrementalDataRecord
|
|
753
|
+
);
|
|
754
|
+
}
|
|
441
755
|
if (!(0, import_isIterableObject.isIterableObject)(result)) {
|
|
442
756
|
throw new import_graphql.GraphQLError(
|
|
443
757
|
`Expected Iterable, but did not find one for field "${info.parentTypeName}.${info.fieldName}".`
|
|
444
758
|
);
|
|
445
759
|
}
|
|
760
|
+
const stream = getStreamValues(exeContext, fieldGroup, path);
|
|
446
761
|
let containsPromise = false;
|
|
447
|
-
|
|
762
|
+
let previousIncrementalDataRecord = incrementalDataRecord;
|
|
763
|
+
const completedResults = [];
|
|
764
|
+
let index = 0;
|
|
765
|
+
for (const item of result) {
|
|
448
766
|
const itemPath = (0, import_Path.addPath)(path, index, void 0);
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
767
|
+
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
768
|
+
previousIncrementalDataRecord = executeStreamField(
|
|
769
|
+
path,
|
|
770
|
+
itemPath,
|
|
771
|
+
item,
|
|
772
|
+
exeContext,
|
|
773
|
+
fieldGroup,
|
|
774
|
+
info,
|
|
775
|
+
itemType,
|
|
776
|
+
stream.label,
|
|
777
|
+
previousIncrementalDataRecord
|
|
778
|
+
);
|
|
779
|
+
index++;
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (completeListItemValue(
|
|
783
|
+
item,
|
|
784
|
+
completedResults,
|
|
785
|
+
exeContext,
|
|
786
|
+
itemType,
|
|
787
|
+
fieldGroup,
|
|
788
|
+
info,
|
|
789
|
+
itemPath,
|
|
790
|
+
incrementalDataRecord
|
|
791
|
+
)) {
|
|
792
|
+
containsPromise = true;
|
|
793
|
+
}
|
|
794
|
+
index++;
|
|
795
|
+
}
|
|
796
|
+
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
797
|
+
}
|
|
798
|
+
function completeListItemValue(item, completedResults, exeContext, itemTypeNode, fieldGroup, info, itemPath, incrementalDataRecord) {
|
|
799
|
+
if ((0, import_isPromise.isPromise)(item)) {
|
|
800
|
+
completedResults.push(
|
|
801
|
+
completePromisedValue(
|
|
802
|
+
exeContext,
|
|
803
|
+
itemTypeNode,
|
|
804
|
+
fieldGroup,
|
|
805
|
+
info,
|
|
806
|
+
itemPath,
|
|
807
|
+
item,
|
|
808
|
+
incrementalDataRecord
|
|
809
|
+
)
|
|
810
|
+
);
|
|
811
|
+
return true;
|
|
812
|
+
}
|
|
813
|
+
try {
|
|
814
|
+
const completedItem = completeValue(
|
|
815
|
+
exeContext,
|
|
816
|
+
itemTypeNode,
|
|
817
|
+
fieldGroup,
|
|
818
|
+
info,
|
|
819
|
+
itemPath,
|
|
820
|
+
item,
|
|
821
|
+
incrementalDataRecord
|
|
822
|
+
);
|
|
823
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
824
|
+
completedResults.push(
|
|
825
|
+
completedItem.then(void 0, (rawError) => {
|
|
826
|
+
handleFieldError(
|
|
827
|
+
rawError,
|
|
454
828
|
exeContext,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
info,
|
|
829
|
+
itemTypeNode,
|
|
830
|
+
fieldGroup,
|
|
458
831
|
itemPath,
|
|
459
|
-
|
|
460
|
-
)
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
832
|
+
incrementalDataRecord
|
|
833
|
+
);
|
|
834
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
835
|
+
return null;
|
|
836
|
+
})
|
|
837
|
+
);
|
|
838
|
+
return true;
|
|
839
|
+
}
|
|
840
|
+
completedResults.push(completedItem);
|
|
841
|
+
} catch (rawError) {
|
|
842
|
+
handleFieldError(
|
|
843
|
+
rawError,
|
|
844
|
+
exeContext,
|
|
845
|
+
itemTypeNode,
|
|
846
|
+
fieldGroup,
|
|
847
|
+
itemPath,
|
|
848
|
+
incrementalDataRecord
|
|
849
|
+
);
|
|
850
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
851
|
+
completedResults.push(null);
|
|
852
|
+
}
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
function getStreamValues(exeContext, fieldGroup, path) {
|
|
856
|
+
if (typeof path.key === "number") {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const stream = (0, import_values.getDirectiveValues)(
|
|
860
|
+
import_directives.GraphQLStreamDirective,
|
|
861
|
+
fieldGroup[0],
|
|
862
|
+
exeContext.resolvers,
|
|
863
|
+
exeContext.variableValues
|
|
864
|
+
);
|
|
865
|
+
if (!stream) {
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
if (stream.if === false) {
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
(0, import_invariant.invariant)(
|
|
872
|
+
typeof stream.initialCount === "number",
|
|
873
|
+
"initialCount must be a number"
|
|
874
|
+
);
|
|
875
|
+
(0, import_invariant.invariant)(
|
|
876
|
+
stream.initialCount >= 0,
|
|
877
|
+
"initialCount must be a positive integer"
|
|
878
|
+
);
|
|
879
|
+
(0, import_invariant.invariant)(
|
|
880
|
+
exeContext.operation.operation !== import_supermassive_ast.OperationTypeNode.SUBSCRIPTION,
|
|
881
|
+
"`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`."
|
|
882
|
+
);
|
|
883
|
+
return {
|
|
884
|
+
initialCount: stream.initialCount,
|
|
885
|
+
label: typeof stream.label === "string" ? stream.label : void 0
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
function completeAsyncIteratorValue(exeContext, itemType, fieldGroup, info, path, asyncIterator, incrementalDataRecord) {
|
|
889
|
+
return __async(this, null, function* () {
|
|
890
|
+
const stream = getStreamValues(exeContext, fieldGroup, path);
|
|
891
|
+
let containsPromise = false;
|
|
892
|
+
const completedResults = [];
|
|
893
|
+
let index = 0;
|
|
894
|
+
while (true) {
|
|
895
|
+
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
896
|
+
executeStreamAsyncIterator(
|
|
897
|
+
index,
|
|
898
|
+
asyncIterator,
|
|
464
899
|
exeContext,
|
|
465
|
-
|
|
466
|
-
fieldNodes,
|
|
900
|
+
fieldGroup,
|
|
467
901
|
info,
|
|
468
|
-
|
|
469
|
-
|
|
902
|
+
itemType,
|
|
903
|
+
path,
|
|
904
|
+
stream.label,
|
|
905
|
+
incrementalDataRecord
|
|
470
906
|
);
|
|
907
|
+
break;
|
|
471
908
|
}
|
|
472
|
-
|
|
909
|
+
const itemPath = (0, import_Path.addPath)(path, index, void 0);
|
|
910
|
+
let iteration;
|
|
911
|
+
try {
|
|
912
|
+
iteration = yield asyncIterator.next();
|
|
913
|
+
if (iteration.done) {
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
} catch (rawError) {
|
|
917
|
+
throw (0, import_graphql.locatedError)(
|
|
918
|
+
rawError,
|
|
919
|
+
fieldGroup,
|
|
920
|
+
(0, import_Path.pathToArray)(path)
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
if (completeListItemValue(
|
|
924
|
+
iteration.value,
|
|
925
|
+
completedResults,
|
|
926
|
+
exeContext,
|
|
927
|
+
itemType,
|
|
928
|
+
fieldGroup,
|
|
929
|
+
info,
|
|
930
|
+
itemPath,
|
|
931
|
+
incrementalDataRecord
|
|
932
|
+
)) {
|
|
473
933
|
containsPromise = true;
|
|
474
|
-
return completedItem.then(void 0, (rawError) => {
|
|
475
|
-
const error = (0, import_graphql.locatedError)(
|
|
476
|
-
rawError,
|
|
477
|
-
fieldNodes,
|
|
478
|
-
(0, import_Path.pathToArray)(itemPath)
|
|
479
|
-
);
|
|
480
|
-
return handleFieldError(error, returnTypeNode, exeContext);
|
|
481
|
-
});
|
|
482
934
|
}
|
|
483
|
-
|
|
484
|
-
} catch (rawError) {
|
|
485
|
-
const error = (0, import_graphql.locatedError)(
|
|
486
|
-
rawError,
|
|
487
|
-
fieldNodes,
|
|
488
|
-
(0, import_Path.pathToArray)(itemPath)
|
|
489
|
-
);
|
|
490
|
-
return handleFieldError(error, returnTypeNode, exeContext);
|
|
935
|
+
index += 1;
|
|
491
936
|
}
|
|
937
|
+
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
492
938
|
});
|
|
493
|
-
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
494
939
|
}
|
|
495
940
|
function completeLeafValue(returnType, result) {
|
|
496
941
|
const serializedResult = returnType.serialize(result);
|
|
@@ -501,7 +946,7 @@ function completeLeafValue(returnType, result) {
|
|
|
501
946
|
}
|
|
502
947
|
return serializedResult;
|
|
503
948
|
}
|
|
504
|
-
function completeAbstractValue(exeContext, returnType,
|
|
949
|
+
function completeAbstractValue(exeContext, returnType, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
505
950
|
var _a;
|
|
506
951
|
const resolveTypeFn = (_a = returnType.__resolveType) != null ? _a : exeContext.typeResolver;
|
|
507
952
|
const contextValue = exeContext.contextValue;
|
|
@@ -511,20 +956,20 @@ function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, r
|
|
|
511
956
|
(resolvedRuntimeTypeName) => completeObjectValue(
|
|
512
957
|
exeContext,
|
|
513
958
|
ensureValidRuntimeType(resolvedRuntimeTypeName, exeContext),
|
|
514
|
-
|
|
515
|
-
info,
|
|
959
|
+
fieldGroup,
|
|
516
960
|
path,
|
|
517
|
-
result
|
|
961
|
+
result,
|
|
962
|
+
incrementalDataRecord
|
|
518
963
|
)
|
|
519
964
|
);
|
|
520
965
|
}
|
|
521
966
|
return completeObjectValue(
|
|
522
967
|
exeContext,
|
|
523
968
|
ensureValidRuntimeType(runtimeTypeName, exeContext),
|
|
524
|
-
|
|
525
|
-
info,
|
|
969
|
+
fieldGroup,
|
|
526
970
|
path,
|
|
527
|
-
result
|
|
971
|
+
result,
|
|
972
|
+
incrementalDataRecord
|
|
528
973
|
);
|
|
529
974
|
}
|
|
530
975
|
function ensureValidRuntimeType(runtimeTypeName, exeContext) {
|
|
@@ -563,31 +1008,39 @@ function getRuntimeTypeInstanceName(runtimeType) {
|
|
|
563
1008
|
return "Unknown";
|
|
564
1009
|
}
|
|
565
1010
|
}
|
|
566
|
-
function completeObjectValue(exeContext, returnTypeName,
|
|
567
|
-
|
|
1011
|
+
function completeObjectValue(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
1012
|
+
return collectAndExecuteSubfields(
|
|
568
1013
|
exeContext,
|
|
569
1014
|
returnTypeName,
|
|
570
|
-
|
|
1015
|
+
fieldGroup,
|
|
1016
|
+
path,
|
|
1017
|
+
result,
|
|
1018
|
+
incrementalDataRecord
|
|
571
1019
|
);
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
1020
|
+
}
|
|
1021
|
+
function collectAndExecuteSubfields(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
1022
|
+
const { groupedFieldSet: subGroupedFieldSet, patches: subPatches } = collectSubfields(exeContext, { name: returnTypeName }, fieldGroup);
|
|
1023
|
+
const subFields = executeFields(
|
|
1024
|
+
exeContext,
|
|
1025
|
+
returnTypeName,
|
|
1026
|
+
result,
|
|
1027
|
+
path,
|
|
1028
|
+
subGroupedFieldSet,
|
|
1029
|
+
incrementalDataRecord
|
|
1030
|
+
);
|
|
1031
|
+
for (const subPatch of subPatches) {
|
|
1032
|
+
const { label, groupedFieldSet: subPatchGroupedFieldSet } = subPatch;
|
|
1033
|
+
executeDeferredFragment(
|
|
1034
|
+
exeContext,
|
|
1035
|
+
returnTypeName,
|
|
1036
|
+
result,
|
|
1037
|
+
subPatchGroupedFieldSet,
|
|
1038
|
+
label,
|
|
1039
|
+
path,
|
|
1040
|
+
incrementalDataRecord
|
|
1041
|
+
);
|
|
589
1042
|
}
|
|
590
|
-
return
|
|
1043
|
+
return subFields;
|
|
591
1044
|
}
|
|
592
1045
|
function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
593
1046
|
var _a;
|
|
@@ -698,11 +1151,412 @@ const defaultFieldResolver = (
|
|
|
698
1151
|
);
|
|
699
1152
|
function getOperationRootTypeName(operation) {
|
|
700
1153
|
switch (operation.operation) {
|
|
701
|
-
case
|
|
1154
|
+
case import_supermassive_ast.OperationTypeNode.QUERY:
|
|
702
1155
|
return "Query";
|
|
703
|
-
case
|
|
1156
|
+
case import_supermassive_ast.OperationTypeNode.MUTATION:
|
|
704
1157
|
return "Mutation";
|
|
705
|
-
case
|
|
1158
|
+
case import_supermassive_ast.OperationTypeNode.SUBSCRIPTION:
|
|
706
1159
|
return "Subscription";
|
|
707
1160
|
}
|
|
708
1161
|
}
|
|
1162
|
+
function executeDeferredFragment(exeContext, parentTypeName, sourceValue, fields, label, path, parentContext) {
|
|
1163
|
+
const incrementalDataRecord = new DeferredFragmentRecord({
|
|
1164
|
+
label,
|
|
1165
|
+
path,
|
|
1166
|
+
parentContext,
|
|
1167
|
+
exeContext
|
|
1168
|
+
});
|
|
1169
|
+
let promiseOrData;
|
|
1170
|
+
try {
|
|
1171
|
+
promiseOrData = executeFields(
|
|
1172
|
+
exeContext,
|
|
1173
|
+
parentTypeName,
|
|
1174
|
+
sourceValue,
|
|
1175
|
+
path,
|
|
1176
|
+
fields,
|
|
1177
|
+
incrementalDataRecord
|
|
1178
|
+
);
|
|
1179
|
+
if ((0, import_isPromise.isPromise)(promiseOrData)) {
|
|
1180
|
+
promiseOrData = promiseOrData.then(null, (e) => {
|
|
1181
|
+
incrementalDataRecord.errors.push(e);
|
|
1182
|
+
return null;
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
} catch (e) {
|
|
1186
|
+
incrementalDataRecord.errors.push(e);
|
|
1187
|
+
promiseOrData = null;
|
|
1188
|
+
}
|
|
1189
|
+
incrementalDataRecord.addData(promiseOrData);
|
|
1190
|
+
}
|
|
1191
|
+
function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info, itemTypeNode, label, parentContext) {
|
|
1192
|
+
const incrementalDataRecord = new StreamItemsRecord({
|
|
1193
|
+
label,
|
|
1194
|
+
path: itemPath,
|
|
1195
|
+
parentContext,
|
|
1196
|
+
exeContext
|
|
1197
|
+
});
|
|
1198
|
+
if ((0, import_isPromise.isPromise)(item)) {
|
|
1199
|
+
const completedItems = completePromisedValue(
|
|
1200
|
+
exeContext,
|
|
1201
|
+
itemTypeNode,
|
|
1202
|
+
fieldGroup,
|
|
1203
|
+
info,
|
|
1204
|
+
itemPath,
|
|
1205
|
+
item,
|
|
1206
|
+
incrementalDataRecord
|
|
1207
|
+
).then(
|
|
1208
|
+
(value) => [value],
|
|
1209
|
+
(error) => {
|
|
1210
|
+
incrementalDataRecord.errors.push(error);
|
|
1211
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1212
|
+
return null;
|
|
1213
|
+
}
|
|
1214
|
+
);
|
|
1215
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1216
|
+
return incrementalDataRecord;
|
|
1217
|
+
}
|
|
1218
|
+
let completedItem;
|
|
1219
|
+
try {
|
|
1220
|
+
try {
|
|
1221
|
+
completedItem = completeValue(
|
|
1222
|
+
exeContext,
|
|
1223
|
+
itemTypeNode,
|
|
1224
|
+
fieldGroup,
|
|
1225
|
+
info,
|
|
1226
|
+
itemPath,
|
|
1227
|
+
item,
|
|
1228
|
+
incrementalDataRecord
|
|
1229
|
+
);
|
|
1230
|
+
} catch (rawError) {
|
|
1231
|
+
handleFieldError(
|
|
1232
|
+
rawError,
|
|
1233
|
+
exeContext,
|
|
1234
|
+
itemTypeNode,
|
|
1235
|
+
fieldGroup,
|
|
1236
|
+
itemPath,
|
|
1237
|
+
incrementalDataRecord
|
|
1238
|
+
);
|
|
1239
|
+
completedItem = null;
|
|
1240
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1241
|
+
}
|
|
1242
|
+
} catch (error) {
|
|
1243
|
+
incrementalDataRecord.errors.push(error);
|
|
1244
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1245
|
+
incrementalDataRecord.addItems(null);
|
|
1246
|
+
return incrementalDataRecord;
|
|
1247
|
+
}
|
|
1248
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
1249
|
+
const completedItems = completedItem.then(void 0, (rawError) => {
|
|
1250
|
+
handleFieldError(
|
|
1251
|
+
rawError,
|
|
1252
|
+
exeContext,
|
|
1253
|
+
itemTypeNode,
|
|
1254
|
+
fieldGroup,
|
|
1255
|
+
itemPath,
|
|
1256
|
+
incrementalDataRecord
|
|
1257
|
+
);
|
|
1258
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1259
|
+
return null;
|
|
1260
|
+
}).then(
|
|
1261
|
+
(value) => [value],
|
|
1262
|
+
(error) => {
|
|
1263
|
+
incrementalDataRecord.errors.push(error);
|
|
1264
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1265
|
+
return null;
|
|
1266
|
+
}
|
|
1267
|
+
);
|
|
1268
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1269
|
+
return incrementalDataRecord;
|
|
1270
|
+
}
|
|
1271
|
+
incrementalDataRecord.addItems([completedItem]);
|
|
1272
|
+
return incrementalDataRecord;
|
|
1273
|
+
}
|
|
1274
|
+
function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, info, itemTypeNode, incrementalDataRecord, path, itemPath) {
|
|
1275
|
+
return __async(this, null, function* () {
|
|
1276
|
+
let item;
|
|
1277
|
+
try {
|
|
1278
|
+
const { value, done } = yield asyncIterator.next();
|
|
1279
|
+
if (done) {
|
|
1280
|
+
incrementalDataRecord.setIsCompletedAsyncIterator();
|
|
1281
|
+
return { done, value: void 0 };
|
|
1282
|
+
}
|
|
1283
|
+
item = value;
|
|
1284
|
+
} catch (rawError) {
|
|
1285
|
+
throw (0, import_graphql.locatedError)(
|
|
1286
|
+
rawError,
|
|
1287
|
+
fieldGroup,
|
|
1288
|
+
(0, import_Path.pathToArray)(path)
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
let completedItem;
|
|
1292
|
+
try {
|
|
1293
|
+
completedItem = completeValue(
|
|
1294
|
+
exeContext,
|
|
1295
|
+
itemTypeNode,
|
|
1296
|
+
fieldGroup,
|
|
1297
|
+
info,
|
|
1298
|
+
itemPath,
|
|
1299
|
+
item,
|
|
1300
|
+
incrementalDataRecord
|
|
1301
|
+
);
|
|
1302
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
1303
|
+
completedItem = completedItem.then(void 0, (rawError) => {
|
|
1304
|
+
handleFieldError(
|
|
1305
|
+
rawError,
|
|
1306
|
+
exeContext,
|
|
1307
|
+
itemTypeNode,
|
|
1308
|
+
fieldGroup,
|
|
1309
|
+
itemPath,
|
|
1310
|
+
incrementalDataRecord
|
|
1311
|
+
);
|
|
1312
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1313
|
+
return null;
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
return { done: false, value: completedItem };
|
|
1317
|
+
} catch (rawError) {
|
|
1318
|
+
handleFieldError(
|
|
1319
|
+
rawError,
|
|
1320
|
+
exeContext,
|
|
1321
|
+
itemTypeNode,
|
|
1322
|
+
fieldGroup,
|
|
1323
|
+
itemPath,
|
|
1324
|
+
incrementalDataRecord
|
|
1325
|
+
);
|
|
1326
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1327
|
+
return { done: false, value: null };
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fieldGroup, info, itemTypeNode, path, label, parentContext) {
|
|
1332
|
+
return __async(this, null, function* () {
|
|
1333
|
+
let index = initialIndex;
|
|
1334
|
+
let previousIncrementalDataRecord = parentContext != null ? parentContext : void 0;
|
|
1335
|
+
while (true) {
|
|
1336
|
+
const itemPath = (0, import_Path.addPath)(path, index, void 0);
|
|
1337
|
+
const incrementalDataRecord = new StreamItemsRecord({
|
|
1338
|
+
label,
|
|
1339
|
+
path: itemPath,
|
|
1340
|
+
parentContext: previousIncrementalDataRecord,
|
|
1341
|
+
asyncIterator,
|
|
1342
|
+
exeContext
|
|
1343
|
+
});
|
|
1344
|
+
let iteration;
|
|
1345
|
+
try {
|
|
1346
|
+
iteration = yield executeStreamAsyncIteratorItem(
|
|
1347
|
+
asyncIterator,
|
|
1348
|
+
exeContext,
|
|
1349
|
+
fieldGroup,
|
|
1350
|
+
info,
|
|
1351
|
+
itemTypeNode,
|
|
1352
|
+
incrementalDataRecord,
|
|
1353
|
+
path,
|
|
1354
|
+
itemPath
|
|
1355
|
+
);
|
|
1356
|
+
} catch (error) {
|
|
1357
|
+
incrementalDataRecord.errors.push(error);
|
|
1358
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1359
|
+
incrementalDataRecord.addItems(null);
|
|
1360
|
+
if (asyncIterator == null ? void 0 : asyncIterator.return) {
|
|
1361
|
+
asyncIterator.return().catch(() => {
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
const { done, value: completedItem } = iteration;
|
|
1367
|
+
let completedItems;
|
|
1368
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
1369
|
+
completedItems = completedItem.then(
|
|
1370
|
+
(value) => [value],
|
|
1371
|
+
(error) => {
|
|
1372
|
+
incrementalDataRecord.errors.push(error);
|
|
1373
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
);
|
|
1377
|
+
} else {
|
|
1378
|
+
completedItems = [completedItem];
|
|
1379
|
+
}
|
|
1380
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1381
|
+
if (done) {
|
|
1382
|
+
break;
|
|
1383
|
+
}
|
|
1384
|
+
previousIncrementalDataRecord = incrementalDataRecord;
|
|
1385
|
+
index++;
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
function filterSubsequentPayloads(exeContext, nullPath, currentIncrementalDataRecord) {
|
|
1390
|
+
const nullPathArray = (0, import_Path.pathToArray)(nullPath);
|
|
1391
|
+
exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {
|
|
1392
|
+
var _a;
|
|
1393
|
+
if (incrementalDataRecord === currentIncrementalDataRecord) {
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
for (let i = 0; i < nullPathArray.length; i++) {
|
|
1397
|
+
if (incrementalDataRecord.path[i] !== nullPathArray[i]) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
if (isStreamItemsRecord(incrementalDataRecord) && ((_a = incrementalDataRecord.asyncIterator) == null ? void 0 : _a.return)) {
|
|
1402
|
+
incrementalDataRecord.asyncIterator.return().catch(() => {
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
exeContext.subsequentPayloads.delete(incrementalDataRecord);
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
function getCompletedIncrementalResults(exeContext) {
|
|
1409
|
+
const incrementalResults = [];
|
|
1410
|
+
for (const incrementalDataRecord of exeContext.subsequentPayloads) {
|
|
1411
|
+
const incrementalResult = {};
|
|
1412
|
+
if (!incrementalDataRecord.isCompleted) {
|
|
1413
|
+
continue;
|
|
1414
|
+
}
|
|
1415
|
+
exeContext.subsequentPayloads.delete(incrementalDataRecord);
|
|
1416
|
+
if (isStreamItemsRecord(incrementalDataRecord)) {
|
|
1417
|
+
const items = incrementalDataRecord.items;
|
|
1418
|
+
if (incrementalDataRecord.isCompletedAsyncIterator) {
|
|
1419
|
+
continue;
|
|
1420
|
+
}
|
|
1421
|
+
incrementalResult.items = items;
|
|
1422
|
+
} else {
|
|
1423
|
+
const data = incrementalDataRecord.data;
|
|
1424
|
+
incrementalResult.data = data != null ? data : null;
|
|
1425
|
+
}
|
|
1426
|
+
incrementalResult.path = incrementalDataRecord.path;
|
|
1427
|
+
if (incrementalDataRecord.label != null) {
|
|
1428
|
+
incrementalResult.label = incrementalDataRecord.label;
|
|
1429
|
+
}
|
|
1430
|
+
if (incrementalDataRecord.errors.length > 0) {
|
|
1431
|
+
incrementalResult.errors = incrementalDataRecord.errors;
|
|
1432
|
+
}
|
|
1433
|
+
incrementalResults.push(incrementalResult);
|
|
1434
|
+
}
|
|
1435
|
+
return incrementalResults;
|
|
1436
|
+
}
|
|
1437
|
+
function yieldSubsequentPayloads(exeContext) {
|
|
1438
|
+
let isDone = false;
|
|
1439
|
+
function next() {
|
|
1440
|
+
return __async(this, null, function* () {
|
|
1441
|
+
if (isDone) {
|
|
1442
|
+
return { value: void 0, done: true };
|
|
1443
|
+
}
|
|
1444
|
+
yield Promise.race(
|
|
1445
|
+
Array.from(exeContext.subsequentPayloads).map((p) => p.promise)
|
|
1446
|
+
);
|
|
1447
|
+
if (isDone) {
|
|
1448
|
+
return { value: void 0, done: true };
|
|
1449
|
+
}
|
|
1450
|
+
const incremental = getCompletedIncrementalResults(exeContext);
|
|
1451
|
+
const hasNext = exeContext.subsequentPayloads.size > 0;
|
|
1452
|
+
if (!incremental.length && hasNext) {
|
|
1453
|
+
return next();
|
|
1454
|
+
}
|
|
1455
|
+
if (!hasNext) {
|
|
1456
|
+
isDone = true;
|
|
1457
|
+
}
|
|
1458
|
+
return {
|
|
1459
|
+
value: incremental.length ? { incremental, hasNext } : { hasNext },
|
|
1460
|
+
done: false
|
|
1461
|
+
};
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
function returnStreamIterators() {
|
|
1465
|
+
const promises = [];
|
|
1466
|
+
exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {
|
|
1467
|
+
var _a2;
|
|
1468
|
+
if (isStreamItemsRecord(incrementalDataRecord) && ((_a2 = incrementalDataRecord.asyncIterator) == null ? void 0 : _a2.return)) {
|
|
1469
|
+
promises.push(incrementalDataRecord.asyncIterator.return());
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
return Promise.all(promises);
|
|
1473
|
+
}
|
|
1474
|
+
return {
|
|
1475
|
+
[Symbol.asyncIterator]() {
|
|
1476
|
+
return this;
|
|
1477
|
+
},
|
|
1478
|
+
next,
|
|
1479
|
+
return() {
|
|
1480
|
+
return __async(this, null, function* () {
|
|
1481
|
+
yield returnStreamIterators();
|
|
1482
|
+
isDone = true;
|
|
1483
|
+
return { value: void 0, done: true };
|
|
1484
|
+
});
|
|
1485
|
+
},
|
|
1486
|
+
throw(error) {
|
|
1487
|
+
return __async(this, null, function* () {
|
|
1488
|
+
yield returnStreamIterators();
|
|
1489
|
+
isDone = true;
|
|
1490
|
+
return Promise.reject(error);
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
function isStreamItemsRecord(incrementalDataRecord) {
|
|
1496
|
+
return incrementalDataRecord.type === "stream";
|
|
1497
|
+
}
|
|
1498
|
+
class DeferredFragmentRecord {
|
|
1499
|
+
constructor(opts) {
|
|
1500
|
+
this.type = "defer";
|
|
1501
|
+
this.label = opts.label;
|
|
1502
|
+
this.path = (0, import_Path.pathToArray)(opts.path);
|
|
1503
|
+
this.parentContext = opts.parentContext;
|
|
1504
|
+
this.errors = [];
|
|
1505
|
+
this._exeContext = opts.exeContext;
|
|
1506
|
+
this._exeContext.subsequentPayloads.add(this);
|
|
1507
|
+
this.isCompleted = false;
|
|
1508
|
+
this.data = null;
|
|
1509
|
+
this.promise = new Promise((resolve) => {
|
|
1510
|
+
this._resolve = (promiseOrValue) => {
|
|
1511
|
+
resolve(promiseOrValue);
|
|
1512
|
+
};
|
|
1513
|
+
}).then((data) => {
|
|
1514
|
+
this.data = data;
|
|
1515
|
+
this.isCompleted = true;
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
addData(data) {
|
|
1519
|
+
var _a, _b, _c;
|
|
1520
|
+
const parentData = (_a = this.parentContext) == null ? void 0 : _a.promise;
|
|
1521
|
+
if (parentData) {
|
|
1522
|
+
(_b = this._resolve) == null ? void 0 : _b.call(this, parentData.then(() => data));
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
(_c = this._resolve) == null ? void 0 : _c.call(this, data);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
class StreamItemsRecord {
|
|
1529
|
+
constructor(opts) {
|
|
1530
|
+
this.type = "stream";
|
|
1531
|
+
this.items = null;
|
|
1532
|
+
this.label = opts.label;
|
|
1533
|
+
this.path = (0, import_Path.pathToArray)(opts.path);
|
|
1534
|
+
this.parentContext = opts.parentContext;
|
|
1535
|
+
this.asyncIterator = opts.asyncIterator;
|
|
1536
|
+
this.errors = [];
|
|
1537
|
+
this._exeContext = opts.exeContext;
|
|
1538
|
+
this._exeContext.subsequentPayloads.add(this);
|
|
1539
|
+
this.isCompleted = false;
|
|
1540
|
+
this.items = null;
|
|
1541
|
+
this.promise = new Promise((resolve) => {
|
|
1542
|
+
this._resolve = (promiseOrValue) => {
|
|
1543
|
+
resolve(promiseOrValue);
|
|
1544
|
+
};
|
|
1545
|
+
}).then((items) => {
|
|
1546
|
+
this.items = items;
|
|
1547
|
+
this.isCompleted = true;
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
addItems(items) {
|
|
1551
|
+
var _a, _b, _c;
|
|
1552
|
+
const parentData = (_a = this.parentContext) == null ? void 0 : _a.promise;
|
|
1553
|
+
if (parentData) {
|
|
1554
|
+
(_b = this._resolve) == null ? void 0 : _b.call(this, parentData.then(() => items));
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
(_c = this._resolve) == null ? void 0 : _c.call(this, items);
|
|
1558
|
+
}
|
|
1559
|
+
setIsCompletedAsyncIterator() {
|
|
1560
|
+
this.isCompletedAsyncIterator = true;
|
|
1561
|
+
}
|
|
1562
|
+
}
|