@graphitation/supermassive 3.3.0 → 3.4.0
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 +10 -2
- package/lib/collectFields.d.ts +8 -21
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +95 -97
- package/lib/collectFields.js.map +2 -2
- package/lib/collectFields.mjs +95 -97
- package/lib/collectFields.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +50 -6
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +517 -622
- package/lib/executeWithoutSchema.js.map +3 -3
- package/lib/executeWithoutSchema.mjs +518 -633
- package/lib/executeWithoutSchema.mjs.map +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/types.d.ts +27 -63
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/values.d.ts +4 -5
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +8 -13
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +8 -13
- package/lib/values.mjs.map +2 -2
- package/package.json +1 -1
- package/lib/IncrementalPublisher.d.ts +0 -131
- package/lib/IncrementalPublisher.d.ts.map +0 -1
- package/lib/IncrementalPublisher.js +0 -519
- package/lib/IncrementalPublisher.js.map +0 -7
- package/lib/IncrementalPublisher.mjs +0 -503
- package/lib/IncrementalPublisher.mjs.map +0 -7
- package/lib/buildFieldPlan.d.ts +0 -18
- package/lib/buildFieldPlan.d.ts.map +0 -1
- package/lib/buildFieldPlan.js +0 -120
- package/lib/buildFieldPlan.js.map +0 -7
- package/lib/buildFieldPlan.mjs +0 -101
- package/lib/buildFieldPlan.mjs.map +0 -7
- package/lib/jsutils/getBySet.d.ts +0 -2
- package/lib/jsutils/getBySet.d.ts.map +0 -1
- package/lib/jsutils/getBySet.js +0 -32
- package/lib/jsutils/getBySet.js.map +0 -7
- package/lib/jsutils/getBySet.mjs +0 -13
- package/lib/jsutils/getBySet.mjs.map +0 -7
- package/lib/jsutils/isSameSet.d.ts +0 -2
- package/lib/jsutils/isSameSet.d.ts.map +0 -1
- package/lib/jsutils/isSameSet.js +0 -34
- package/lib/jsutils/isSameSet.js.map +0 -7
- package/lib/jsutils/isSameSet.mjs +0 -15
- package/lib/jsutils/isSameSet.mjs.map +0 -7
- package/lib/jsutils/promiseWithResolvers.d.ts +0 -11
- package/lib/jsutils/promiseWithResolvers.d.ts.map +0 -1
- package/lib/jsutils/promiseWithResolvers.js +0 -32
- package/lib/jsutils/promiseWithResolvers.js.map +0 -7
- package/lib/jsutils/promiseWithResolvers.mjs +0 -13
- package/lib/jsutils/promiseWithResolvers.mjs.map +0 -7
|
@@ -40,13 +40,12 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
40
|
|
|
41
41
|
// src/executeWithoutSchema.ts
|
|
42
42
|
import {
|
|
43
|
-
GraphQLError,
|
|
44
43
|
Kind,
|
|
45
44
|
locatedError
|
|
46
45
|
} from "graphql";
|
|
47
46
|
import {
|
|
48
47
|
collectFields,
|
|
49
|
-
collectSubfields
|
|
48
|
+
collectSubfields as _collectSubfields
|
|
50
49
|
} from "./collectFields.mjs";
|
|
51
50
|
import { devAssert } from "./jsutils/devAssert.mjs";
|
|
52
51
|
import { inspect } from "./jsutils/inspect.mjs";
|
|
@@ -76,40 +75,15 @@ import {
|
|
|
76
75
|
} from "./schema/reference.mjs";
|
|
77
76
|
import * as Definitions from "./schema/definition.mjs";
|
|
78
77
|
import * as Resolvers from "./schema/resolvers.mjs";
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} from "./buildFieldPlan.mjs";
|
|
82
|
-
import {
|
|
83
|
-
DeferredFragmentRecord,
|
|
84
|
-
DeferredGroupedFieldSetRecord,
|
|
85
|
-
IncrementalPublisher,
|
|
86
|
-
InitialResultRecord,
|
|
87
|
-
StreamItemsRecord,
|
|
88
|
-
StreamRecord
|
|
89
|
-
} from "./IncrementalPublisher.mjs";
|
|
90
|
-
var buildSubFieldPlan = memoize3(
|
|
91
|
-
(exeContext, returnTypeName, fieldGroup) => {
|
|
92
|
-
const subFields = collectSubfields(
|
|
93
|
-
exeContext.schemaFragment,
|
|
94
|
-
exeContext.fragments,
|
|
95
|
-
exeContext.variableValues,
|
|
96
|
-
exeContext.operation,
|
|
97
|
-
returnTypeName.name,
|
|
98
|
-
fieldGroup.fields
|
|
99
|
-
);
|
|
100
|
-
return buildFieldPlan(
|
|
101
|
-
subFields,
|
|
102
|
-
fieldGroup.deferUsages,
|
|
103
|
-
fieldGroup.knownDeferUsages
|
|
104
|
-
);
|
|
105
|
-
}
|
|
78
|
+
var collectSubfields = memoize3(
|
|
79
|
+
(exeContext, returnTypeName, fieldGroup) => _collectSubfields(exeContext, returnTypeName.name, fieldGroup)
|
|
106
80
|
);
|
|
107
81
|
function executeWithoutSchema(args) {
|
|
108
82
|
const exeContext = buildExecutionContext(args);
|
|
109
83
|
if (!("schemaFragment" in exeContext)) {
|
|
110
84
|
return { errors: exeContext };
|
|
111
85
|
} else {
|
|
112
|
-
return
|
|
86
|
+
return executeOperation(exeContext);
|
|
113
87
|
}
|
|
114
88
|
}
|
|
115
89
|
function assertValidExecutionArguments(document, rawVariableValues) {
|
|
@@ -188,126 +162,113 @@ function buildExecutionContext(args) {
|
|
|
188
162
|
fieldResolver: fieldResolver != null ? fieldResolver : defaultFieldResolver,
|
|
189
163
|
typeResolver: typeResolver != null ? typeResolver : defaultTypeResolver,
|
|
190
164
|
subscribeFieldResolver: subscribeFieldResolver != null ? subscribeFieldResolver : defaultFieldResolver,
|
|
165
|
+
errors: [],
|
|
191
166
|
fieldExecutionHooks,
|
|
192
|
-
|
|
167
|
+
subsequentPayloads: /* @__PURE__ */ new Set()
|
|
193
168
|
};
|
|
194
169
|
}
|
|
195
170
|
function buildPerEventExecutionContext(exeContext, payload) {
|
|
196
171
|
return __spreadProps(__spreadValues({}, exeContext), {
|
|
197
172
|
contextValue: exeContext.buildContextValue ? exeContext.buildContextValue(exeContext.contextValue) : exeContext.contextValue,
|
|
198
|
-
rootValue: payload
|
|
173
|
+
rootValue: payload,
|
|
174
|
+
subsequentPayloads: /* @__PURE__ */ new Set(),
|
|
175
|
+
errors: []
|
|
199
176
|
});
|
|
200
177
|
}
|
|
201
|
-
function
|
|
202
|
-
const incrementalPublisher = exeContext.incrementalPublisher;
|
|
203
|
-
const initialResultRecord = new InitialResultRecord();
|
|
178
|
+
function executeOperation(exeContext) {
|
|
204
179
|
try {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return resolved;
|
|
211
|
-
} else {
|
|
212
|
-
return incrementalPublisher.buildDataResponse(
|
|
213
|
-
initialResultRecord,
|
|
214
|
-
resolved
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
(error) => incrementalPublisher.buildErrorResponse(initialResultRecord, error)
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
if (isAsyncIterable(data)) {
|
|
222
|
-
return data;
|
|
223
|
-
} else {
|
|
224
|
-
return incrementalPublisher.buildDataResponse(initialResultRecord, data);
|
|
225
|
-
}
|
|
226
|
-
} catch (error) {
|
|
227
|
-
if (exeContext.operation.operation === "subscription") {
|
|
228
|
-
return { errors: [error] };
|
|
229
|
-
} else {
|
|
230
|
-
return incrementalPublisher.buildErrorResponse(
|
|
231
|
-
initialResultRecord,
|
|
232
|
-
error
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
function executeOperation(exeContext, initialResultRecord) {
|
|
238
|
-
const { operation, rootValue, incrementalPublisher } = exeContext;
|
|
239
|
-
const rootTypeName = getOperationRootTypeName(operation);
|
|
240
|
-
if (rootTypeName == null) {
|
|
241
|
-
throw new GraphQLError(
|
|
242
|
-
`Schema is not configured to execute ${operation.operation} operation.`,
|
|
243
|
-
operation
|
|
180
|
+
const { operation, rootValue } = exeContext;
|
|
181
|
+
const rootTypeName = getOperationRootTypeName(operation);
|
|
182
|
+
const { groupedFieldSet, patches } = collectFields(
|
|
183
|
+
exeContext,
|
|
184
|
+
rootTypeName
|
|
244
185
|
);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
186
|
+
const path = void 0;
|
|
187
|
+
let result;
|
|
188
|
+
switch (operation.operation) {
|
|
189
|
+
case "query":
|
|
190
|
+
result = executeFields(
|
|
191
|
+
exeContext,
|
|
192
|
+
rootTypeName,
|
|
193
|
+
rootValue,
|
|
194
|
+
path,
|
|
195
|
+
groupedFieldSet,
|
|
196
|
+
void 0
|
|
197
|
+
);
|
|
198
|
+
result = buildResponse(exeContext, result);
|
|
199
|
+
break;
|
|
200
|
+
case "mutation":
|
|
201
|
+
result = executeFieldsSerially(
|
|
202
|
+
exeContext,
|
|
203
|
+
rootTypeName,
|
|
204
|
+
rootValue,
|
|
205
|
+
path,
|
|
206
|
+
groupedFieldSet
|
|
207
|
+
);
|
|
208
|
+
result = buildResponse(exeContext, result);
|
|
209
|
+
break;
|
|
210
|
+
case "subscription": {
|
|
211
|
+
const resultOrStreamOrPromise = createSourceEventStream(exeContext);
|
|
212
|
+
result = mapResultOrEventStreamOrPromise(
|
|
213
|
+
resultOrStreamOrPromise,
|
|
214
|
+
exeContext,
|
|
215
|
+
rootTypeName,
|
|
216
|
+
path,
|
|
217
|
+
groupedFieldSet
|
|
218
|
+
);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
default:
|
|
222
|
+
invariant(
|
|
223
|
+
false,
|
|
224
|
+
`Operation "${operation.operation}" is not a part of GraphQL spec`
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
for (const patch of patches) {
|
|
228
|
+
const { label, groupedFieldSet: patchGroupedFieldSet } = patch;
|
|
229
|
+
executeDeferredFragment(
|
|
275
230
|
exeContext,
|
|
276
231
|
rootTypeName,
|
|
277
232
|
rootValue,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
newDeferMap
|
|
233
|
+
patchGroupedFieldSet,
|
|
234
|
+
label,
|
|
235
|
+
path
|
|
282
236
|
);
|
|
283
|
-
break;
|
|
284
|
-
case "subscription": {
|
|
285
|
-
const resultOrStreamOrPromise = createSourceEventStream(exeContext);
|
|
286
|
-
result = mapResultOrEventStreamOrPromise(
|
|
287
|
-
resultOrStreamOrPromise,
|
|
288
|
-
exeContext,
|
|
289
|
-
rootTypeName,
|
|
290
|
-
path,
|
|
291
|
-
groupedFieldSet,
|
|
292
|
-
initialResultRecord,
|
|
293
|
-
newDeferMap
|
|
294
|
-
);
|
|
295
|
-
break;
|
|
296
237
|
}
|
|
238
|
+
return result;
|
|
239
|
+
} catch (error) {
|
|
240
|
+
exeContext.errors.push(error);
|
|
241
|
+
return buildResponse(exeContext, null);
|
|
297
242
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
243
|
+
}
|
|
244
|
+
function buildResponse(exeContext, data) {
|
|
245
|
+
if (isPromise(data)) {
|
|
246
|
+
return data.then(
|
|
247
|
+
(resolved) => buildResponse(exeContext, resolved),
|
|
248
|
+
(error) => {
|
|
249
|
+
exeContext.errors.push(error);
|
|
250
|
+
return buildResponse(exeContext, null);
|
|
251
|
+
}
|
|
306
252
|
);
|
|
307
253
|
}
|
|
308
|
-
|
|
254
|
+
try {
|
|
255
|
+
const initialResult = exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
256
|
+
if (exeContext.subsequentPayloads.size > 0) {
|
|
257
|
+
return {
|
|
258
|
+
initialResult: __spreadProps(__spreadValues({}, initialResult), {
|
|
259
|
+
hasNext: true
|
|
260
|
+
}),
|
|
261
|
+
subsequentResults: yieldSubsequentPayloads(exeContext)
|
|
262
|
+
};
|
|
263
|
+
} else {
|
|
264
|
+
return initialResult;
|
|
265
|
+
}
|
|
266
|
+
} catch (error) {
|
|
267
|
+
exeContext.errors.push(error);
|
|
268
|
+
return buildResponse(exeContext, null);
|
|
269
|
+
}
|
|
309
270
|
}
|
|
310
|
-
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, groupedFieldSet
|
|
271
|
+
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, groupedFieldSet) {
|
|
311
272
|
return promiseReduce(
|
|
312
273
|
groupedFieldSet,
|
|
313
274
|
(results, [responseName, fieldGroup]) => {
|
|
@@ -318,8 +279,7 @@ function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, gr
|
|
|
318
279
|
sourceValue,
|
|
319
280
|
fieldGroup,
|
|
320
281
|
fieldPath,
|
|
321
|
-
|
|
322
|
-
deferMap
|
|
282
|
+
void 0
|
|
323
283
|
);
|
|
324
284
|
if (result === void 0) {
|
|
325
285
|
return results;
|
|
@@ -336,7 +296,7 @@ function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, gr
|
|
|
336
296
|
/* @__PURE__ */ Object.create(null)
|
|
337
297
|
);
|
|
338
298
|
}
|
|
339
|
-
function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFieldSet, incrementalDataRecord
|
|
299
|
+
function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFieldSet, incrementalDataRecord) {
|
|
340
300
|
const results = /* @__PURE__ */ Object.create(null);
|
|
341
301
|
let containsPromise = false;
|
|
342
302
|
for (const [responseName, fieldGroup] of groupedFieldSet) {
|
|
@@ -347,8 +307,7 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFie
|
|
|
347
307
|
sourceValue,
|
|
348
308
|
fieldGroup,
|
|
349
309
|
fieldPath,
|
|
350
|
-
incrementalDataRecord
|
|
351
|
-
deferMap
|
|
310
|
+
incrementalDataRecord
|
|
352
311
|
);
|
|
353
312
|
if (result !== void 0) {
|
|
354
313
|
results[responseName] = result;
|
|
@@ -362,9 +321,9 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFie
|
|
|
362
321
|
}
|
|
363
322
|
return promiseForObject(results);
|
|
364
323
|
}
|
|
365
|
-
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord
|
|
324
|
+
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord) {
|
|
366
325
|
const schemaFragment = exeContext.schemaFragment;
|
|
367
|
-
const fieldName = fieldGroup
|
|
326
|
+
const fieldName = fieldGroup[0].name.value;
|
|
368
327
|
const fieldDef = Definitions.getField(
|
|
369
328
|
schemaFragment.definitions,
|
|
370
329
|
parentTypeName,
|
|
@@ -378,8 +337,7 @@ function executeField(exeContext, parentTypeName, source, fieldGroup, path, incr
|
|
|
378
337
|
fieldGroup,
|
|
379
338
|
path,
|
|
380
339
|
source,
|
|
381
|
-
incrementalDataRecord
|
|
382
|
-
deferMap
|
|
340
|
+
incrementalDataRecord
|
|
383
341
|
);
|
|
384
342
|
}
|
|
385
343
|
const loading = requestSchemaFragment(exeContext, {
|
|
@@ -404,8 +362,7 @@ function executeField(exeContext, parentTypeName, source, fieldGroup, path, incr
|
|
|
404
362
|
fieldGroup,
|
|
405
363
|
path,
|
|
406
364
|
source,
|
|
407
|
-
incrementalDataRecord
|
|
408
|
-
deferMap
|
|
365
|
+
incrementalDataRecord
|
|
409
366
|
);
|
|
410
367
|
}
|
|
411
368
|
return void 0;
|
|
@@ -431,16 +388,24 @@ function requestSchemaFragment(exeContext, request) {
|
|
|
431
388
|
});
|
|
432
389
|
}
|
|
433
390
|
function createSourceEventStream(exeContext) {
|
|
434
|
-
|
|
391
|
+
try {
|
|
392
|
+
const eventStream = executeSubscriptionImpl(exeContext);
|
|
393
|
+
if (isPromise(eventStream)) {
|
|
394
|
+
return eventStream.then(void 0, (error) => ({ errors: [error] }));
|
|
395
|
+
}
|
|
396
|
+
return eventStream;
|
|
397
|
+
} catch (error) {
|
|
398
|
+
return { errors: [error] };
|
|
399
|
+
}
|
|
435
400
|
}
|
|
436
401
|
function executeSubscriptionImpl(exeContext) {
|
|
437
402
|
var _a;
|
|
438
|
-
const {
|
|
403
|
+
const { operation, rootValue, schemaFragment } = exeContext;
|
|
439
404
|
const rootTypeName = getOperationRootTypeName(operation);
|
|
440
|
-
const
|
|
441
|
-
const
|
|
442
|
-
const [responseName, fieldGroup] =
|
|
443
|
-
const fieldName =
|
|
405
|
+
const { groupedFieldSet } = collectFields(exeContext, rootTypeName);
|
|
406
|
+
const firstRootField = groupedFieldSet.entries().next().value;
|
|
407
|
+
const [responseName, fieldGroup] = firstRootField;
|
|
408
|
+
const fieldName = fieldGroup[0].name.value;
|
|
444
409
|
const fieldDef = Definitions.getField(
|
|
445
410
|
schemaFragment.definitions,
|
|
446
411
|
rootTypeName,
|
|
@@ -449,7 +414,7 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
449
414
|
if (!fieldDef) {
|
|
450
415
|
throw locatedError(
|
|
451
416
|
`The subscription field "${fieldName}" is not defined.`,
|
|
452
|
-
|
|
417
|
+
fieldGroup
|
|
453
418
|
);
|
|
454
419
|
}
|
|
455
420
|
const returnTypeRef = Definitions.getFieldTypeReference(fieldDef);
|
|
@@ -468,22 +433,17 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
468
433
|
path
|
|
469
434
|
);
|
|
470
435
|
try {
|
|
471
|
-
const args = getArgumentValues(
|
|
472
|
-
exeContext.schemaFragment,
|
|
473
|
-
fieldDef,
|
|
474
|
-
toNodes(fieldGroup)[0],
|
|
475
|
-
exeContext.variableValues
|
|
476
|
-
);
|
|
436
|
+
const args = getArgumentValues(exeContext, fieldDef, fieldGroup[0]);
|
|
477
437
|
const contextValue = exeContext.contextValue;
|
|
478
438
|
const result = resolveFn(rootValue, args, contextValue, info);
|
|
479
439
|
if (isPromise(result)) {
|
|
480
440
|
return result.then(assertEventStream).then(void 0, (error) => {
|
|
481
|
-
throw locatedError(error,
|
|
441
|
+
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
482
442
|
});
|
|
483
443
|
}
|
|
484
444
|
return assertEventStream(result);
|
|
485
445
|
} catch (error) {
|
|
486
|
-
throw locatedError(error,
|
|
446
|
+
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
487
447
|
}
|
|
488
448
|
}
|
|
489
449
|
function assertEventStream(result) {
|
|
@@ -498,7 +458,7 @@ function assertEventStream(result) {
|
|
|
498
458
|
}
|
|
499
459
|
return result;
|
|
500
460
|
}
|
|
501
|
-
function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, parentTypeName, path, groupedFieldSet
|
|
461
|
+
function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, parentTypeName, path, groupedFieldSet) {
|
|
502
462
|
if (isPromise(resultOrStreamOrPromise)) {
|
|
503
463
|
return resultOrStreamOrPromise.then(
|
|
504
464
|
(resultOrStream) => mapResultOrEventStreamOrPromise(
|
|
@@ -506,9 +466,7 @@ function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, pa
|
|
|
506
466
|
exeContext,
|
|
507
467
|
parentTypeName,
|
|
508
468
|
path,
|
|
509
|
-
groupedFieldSet
|
|
510
|
-
initialResultRecord,
|
|
511
|
-
deferMap
|
|
469
|
+
groupedFieldSet
|
|
512
470
|
)
|
|
513
471
|
);
|
|
514
472
|
} else {
|
|
@@ -520,41 +478,19 @@ function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, pa
|
|
|
520
478
|
exeContext,
|
|
521
479
|
payload
|
|
522
480
|
);
|
|
523
|
-
const perEventResultRecord = new InitialResultRecord();
|
|
524
481
|
try {
|
|
525
482
|
const data = executeFields(
|
|
526
|
-
|
|
483
|
+
exeContext,
|
|
527
484
|
parentTypeName,
|
|
528
485
|
payload,
|
|
529
486
|
path,
|
|
530
487
|
groupedFieldSet,
|
|
531
|
-
|
|
532
|
-
deferMap
|
|
488
|
+
void 0
|
|
533
489
|
);
|
|
534
|
-
|
|
535
|
-
return data.then(
|
|
536
|
-
(resolved) => {
|
|
537
|
-
return exeContext.incrementalPublisher.buildDataResponse(
|
|
538
|
-
perEventResultRecord,
|
|
539
|
-
resolved
|
|
540
|
-
);
|
|
541
|
-
},
|
|
542
|
-
(error) => exeContext.incrementalPublisher.buildErrorResponse(
|
|
543
|
-
perEventResultRecord,
|
|
544
|
-
error
|
|
545
|
-
)
|
|
546
|
-
);
|
|
547
|
-
} else {
|
|
548
|
-
return exeContext.incrementalPublisher.buildDataResponse(
|
|
549
|
-
perEventResultRecord,
|
|
550
|
-
data
|
|
551
|
-
);
|
|
552
|
-
}
|
|
490
|
+
return buildResponse(perEventContext, data);
|
|
553
491
|
} catch (error) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
error
|
|
557
|
-
);
|
|
492
|
+
perEventContext.errors.push(error);
|
|
493
|
+
return buildResponse(perEventContext, null);
|
|
558
494
|
}
|
|
559
495
|
};
|
|
560
496
|
return mapAsyncIterator(resultOrStreamOrPromise, mapSourceToResponse);
|
|
@@ -564,7 +500,7 @@ function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, pa
|
|
|
564
500
|
function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, returnTypeName, path) {
|
|
565
501
|
return {
|
|
566
502
|
fieldName,
|
|
567
|
-
fieldNodes:
|
|
503
|
+
fieldNodes: fieldGroup,
|
|
568
504
|
returnTypeName,
|
|
569
505
|
parentTypeName,
|
|
570
506
|
path,
|
|
@@ -575,15 +511,17 @@ function buildResolveInfo(exeContext, fieldName, fieldGroup, parentTypeName, ret
|
|
|
575
511
|
};
|
|
576
512
|
}
|
|
577
513
|
function handleFieldError(rawError, exeContext, returnTypeRef, fieldGroup, path, incrementalDataRecord) {
|
|
578
|
-
|
|
514
|
+
var _a;
|
|
515
|
+
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
579
516
|
if (isNonNullType(returnTypeRef)) {
|
|
580
517
|
throw error;
|
|
581
518
|
}
|
|
582
|
-
|
|
519
|
+
const errors = (_a = incrementalDataRecord == null ? void 0 : incrementalDataRecord.errors) != null ? _a : exeContext.errors;
|
|
520
|
+
errors.push(error);
|
|
583
521
|
}
|
|
584
|
-
function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fieldGroup, path, source, incrementalDataRecord
|
|
522
|
+
function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fieldGroup, path, source, incrementalDataRecord) {
|
|
585
523
|
var _a;
|
|
586
|
-
const fieldName = fieldGroup
|
|
524
|
+
const fieldName = fieldGroup[0].name.value;
|
|
587
525
|
const returnTypeRef = Definitions.getFieldTypeReference(fieldDefinition);
|
|
588
526
|
const resolveFn = (_a = Resolvers.getFieldResolver(
|
|
589
527
|
exeContext.schemaFragment,
|
|
@@ -601,15 +539,10 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
601
539
|
const isDefaultResolverUsed = resolveFn === exeContext.fieldResolver;
|
|
602
540
|
const hooks = exeContext.fieldExecutionHooks;
|
|
603
541
|
try {
|
|
604
|
-
const args = getArgumentValues(
|
|
605
|
-
exeContext.schemaFragment,
|
|
606
|
-
fieldDefinition,
|
|
607
|
-
fieldGroup.fields[0].node,
|
|
608
|
-
exeContext.variableValues
|
|
609
|
-
);
|
|
542
|
+
const args = getArgumentValues(exeContext, fieldDefinition, fieldGroup[0]);
|
|
610
543
|
const contextValue = exeContext.contextValue;
|
|
611
544
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldResolve)) {
|
|
612
|
-
invokeBeforeFieldResolveHook(info, exeContext
|
|
545
|
+
invokeBeforeFieldResolveHook(info, exeContext);
|
|
613
546
|
}
|
|
614
547
|
const result = resolveFn(source, args, contextValue, info);
|
|
615
548
|
let completed;
|
|
@@ -617,12 +550,7 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
617
550
|
completed = result.then(
|
|
618
551
|
(resolved) => {
|
|
619
552
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
620
|
-
invokeAfterFieldResolveHook(
|
|
621
|
-
info,
|
|
622
|
-
exeContext,
|
|
623
|
-
incrementalDataRecord,
|
|
624
|
-
resolved
|
|
625
|
-
);
|
|
553
|
+
invokeAfterFieldResolveHook(info, exeContext, resolved);
|
|
626
554
|
}
|
|
627
555
|
return completeValue(
|
|
628
556
|
exeContext,
|
|
@@ -631,31 +559,19 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
631
559
|
info,
|
|
632
560
|
path,
|
|
633
561
|
resolved,
|
|
634
|
-
incrementalDataRecord
|
|
635
|
-
deferMap
|
|
562
|
+
incrementalDataRecord
|
|
636
563
|
);
|
|
637
564
|
},
|
|
638
565
|
(rawError) => {
|
|
639
566
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
640
|
-
invokeAfterFieldResolveHook(
|
|
641
|
-
info,
|
|
642
|
-
exeContext,
|
|
643
|
-
incrementalDataRecord,
|
|
644
|
-
void 0,
|
|
645
|
-
rawError
|
|
646
|
-
);
|
|
567
|
+
invokeAfterFieldResolveHook(info, exeContext, void 0, rawError);
|
|
647
568
|
}
|
|
648
569
|
throw rawError;
|
|
649
570
|
}
|
|
650
571
|
);
|
|
651
572
|
} else {
|
|
652
573
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
653
|
-
invokeAfterFieldResolveHook(
|
|
654
|
-
info,
|
|
655
|
-
exeContext,
|
|
656
|
-
incrementalDataRecord,
|
|
657
|
-
result
|
|
658
|
-
);
|
|
574
|
+
invokeAfterFieldResolveHook(info, exeContext, result);
|
|
659
575
|
}
|
|
660
576
|
completed = completeValue(
|
|
661
577
|
exeContext,
|
|
@@ -664,37 +580,21 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
664
580
|
info,
|
|
665
581
|
path,
|
|
666
582
|
result,
|
|
667
|
-
incrementalDataRecord
|
|
668
|
-
deferMap
|
|
583
|
+
incrementalDataRecord
|
|
669
584
|
);
|
|
670
585
|
}
|
|
671
586
|
if (isPromise(completed)) {
|
|
672
587
|
return completed.then(
|
|
673
588
|
(resolved) => {
|
|
674
589
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
675
|
-
invokeAfterFieldCompleteHook(
|
|
676
|
-
info,
|
|
677
|
-
exeContext,
|
|
678
|
-
incrementalDataRecord,
|
|
679
|
-
resolved
|
|
680
|
-
);
|
|
590
|
+
invokeAfterFieldCompleteHook(info, exeContext, resolved);
|
|
681
591
|
}
|
|
682
592
|
return resolved;
|
|
683
593
|
},
|
|
684
594
|
(rawError) => {
|
|
685
|
-
const error = locatedError(
|
|
686
|
-
rawError,
|
|
687
|
-
toNodes(fieldGroup),
|
|
688
|
-
pathToArray(path)
|
|
689
|
-
);
|
|
595
|
+
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
690
596
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
691
|
-
invokeAfterFieldCompleteHook(
|
|
692
|
-
info,
|
|
693
|
-
exeContext,
|
|
694
|
-
incrementalDataRecord,
|
|
695
|
-
void 0,
|
|
696
|
-
error
|
|
697
|
-
);
|
|
597
|
+
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
|
|
698
598
|
}
|
|
699
599
|
handleFieldError(
|
|
700
600
|
rawError,
|
|
@@ -709,34 +609,17 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
709
609
|
);
|
|
710
610
|
}
|
|
711
611
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
712
|
-
invokeAfterFieldCompleteHook(
|
|
713
|
-
info,
|
|
714
|
-
exeContext,
|
|
715
|
-
incrementalDataRecord,
|
|
716
|
-
completed
|
|
717
|
-
);
|
|
612
|
+
invokeAfterFieldCompleteHook(info, exeContext, completed);
|
|
718
613
|
}
|
|
719
614
|
return completed;
|
|
720
615
|
} catch (rawError) {
|
|
721
616
|
const pathArray = pathToArray(path);
|
|
722
|
-
const error = locatedError(rawError, fieldGroup
|
|
617
|
+
const error = locatedError(rawError, fieldGroup, pathArray);
|
|
723
618
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve) && error.path && arraysAreEqual(pathArray, error.path)) {
|
|
724
|
-
invokeAfterFieldResolveHook(
|
|
725
|
-
info,
|
|
726
|
-
exeContext,
|
|
727
|
-
incrementalDataRecord,
|
|
728
|
-
void 0,
|
|
729
|
-
error
|
|
730
|
-
);
|
|
619
|
+
invokeAfterFieldResolveHook(info, exeContext, void 0, error);
|
|
731
620
|
}
|
|
732
621
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
733
|
-
invokeAfterFieldCompleteHook(
|
|
734
|
-
info,
|
|
735
|
-
exeContext,
|
|
736
|
-
incrementalDataRecord,
|
|
737
|
-
void 0,
|
|
738
|
-
error
|
|
739
|
-
);
|
|
622
|
+
invokeAfterFieldCompleteHook(info, exeContext, void 0, error);
|
|
740
623
|
}
|
|
741
624
|
handleFieldError(
|
|
742
625
|
rawError,
|
|
@@ -749,7 +632,7 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
749
632
|
return null;
|
|
750
633
|
}
|
|
751
634
|
}
|
|
752
|
-
function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord
|
|
635
|
+
function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
753
636
|
if (result instanceof Error) {
|
|
754
637
|
throw result;
|
|
755
638
|
}
|
|
@@ -761,8 +644,7 @@ function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result
|
|
|
761
644
|
info,
|
|
762
645
|
path,
|
|
763
646
|
result,
|
|
764
|
-
incrementalDataRecord
|
|
765
|
-
deferMap
|
|
647
|
+
incrementalDataRecord
|
|
766
648
|
);
|
|
767
649
|
if (completed === null) {
|
|
768
650
|
throw new Error(
|
|
@@ -782,8 +664,7 @@ function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result
|
|
|
782
664
|
info,
|
|
783
665
|
path,
|
|
784
666
|
result,
|
|
785
|
-
incrementalDataRecord
|
|
786
|
-
deferMap
|
|
667
|
+
incrementalDataRecord
|
|
787
668
|
);
|
|
788
669
|
}
|
|
789
670
|
const { schemaFragment } = exeContext;
|
|
@@ -800,8 +681,7 @@ function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result
|
|
|
800
681
|
info,
|
|
801
682
|
path,
|
|
802
683
|
result,
|
|
803
|
-
incrementalDataRecord
|
|
804
|
-
deferMap
|
|
684
|
+
incrementalDataRecord
|
|
805
685
|
);
|
|
806
686
|
}
|
|
807
687
|
if (Definitions.isObjectType(schemaFragment.definitions, returnTypeRef)) {
|
|
@@ -811,8 +691,7 @@ function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result
|
|
|
811
691
|
fieldGroup,
|
|
812
692
|
path,
|
|
813
693
|
result,
|
|
814
|
-
incrementalDataRecord
|
|
815
|
-
deferMap
|
|
694
|
+
incrementalDataRecord
|
|
816
695
|
);
|
|
817
696
|
}
|
|
818
697
|
invariant(
|
|
@@ -820,7 +699,7 @@ function completeValue(exeContext, returnTypeRef, fieldGroup, info, path, result
|
|
|
820
699
|
"Cannot complete value of unexpected output type: " + inspectTypeReference(returnTypeRef)
|
|
821
700
|
);
|
|
822
701
|
}
|
|
823
|
-
function completePromisedValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord
|
|
702
|
+
function completePromisedValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
824
703
|
return __async(this, null, function* () {
|
|
825
704
|
try {
|
|
826
705
|
const resolved = yield result;
|
|
@@ -831,8 +710,7 @@ function completePromisedValue(exeContext, returnTypeRef, fieldGroup, info, path
|
|
|
831
710
|
info,
|
|
832
711
|
path,
|
|
833
712
|
resolved,
|
|
834
|
-
incrementalDataRecord
|
|
835
|
-
deferMap
|
|
713
|
+
incrementalDataRecord
|
|
836
714
|
);
|
|
837
715
|
if (isPromise(completed)) {
|
|
838
716
|
completed = yield completed;
|
|
@@ -847,12 +725,12 @@ function completePromisedValue(exeContext, returnTypeRef, fieldGroup, info, path
|
|
|
847
725
|
path,
|
|
848
726
|
incrementalDataRecord
|
|
849
727
|
);
|
|
850
|
-
exeContext
|
|
728
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
851
729
|
return null;
|
|
852
730
|
}
|
|
853
731
|
});
|
|
854
732
|
}
|
|
855
|
-
function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord
|
|
733
|
+
function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
856
734
|
const itemTypeRef = unwrap(returnTypeRef);
|
|
857
735
|
if (isAsyncIterable(result)) {
|
|
858
736
|
const asyncIterator = result[Symbol.asyncIterator]();
|
|
@@ -863,8 +741,7 @@ function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, re
|
|
|
863
741
|
info,
|
|
864
742
|
path,
|
|
865
743
|
asyncIterator,
|
|
866
|
-
incrementalDataRecord
|
|
867
|
-
deferMap
|
|
744
|
+
incrementalDataRecord
|
|
868
745
|
);
|
|
869
746
|
}
|
|
870
747
|
if (!isIterableObject(result)) {
|
|
@@ -873,28 +750,24 @@ function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, re
|
|
|
873
750
|
[]
|
|
874
751
|
);
|
|
875
752
|
}
|
|
876
|
-
const
|
|
753
|
+
const stream = getStreamValues(exeContext, fieldGroup, path);
|
|
877
754
|
let containsPromise = false;
|
|
878
|
-
let
|
|
755
|
+
let previousIncrementalDataRecord = incrementalDataRecord;
|
|
879
756
|
const completedResults = [];
|
|
880
757
|
let index = 0;
|
|
881
|
-
let streamRecord;
|
|
882
758
|
for (const item of result) {
|
|
883
759
|
const itemPath = addPath(path, index, void 0);
|
|
884
|
-
if (
|
|
885
|
-
|
|
886
|
-
streamRecord = new StreamRecord({ label: streamUsage.label, path });
|
|
887
|
-
}
|
|
888
|
-
currentParents = executeStreamField(
|
|
760
|
+
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
761
|
+
previousIncrementalDataRecord = executeStreamField(
|
|
889
762
|
path,
|
|
890
763
|
itemPath,
|
|
891
764
|
item,
|
|
892
765
|
exeContext,
|
|
893
|
-
|
|
766
|
+
fieldGroup,
|
|
894
767
|
info,
|
|
895
768
|
itemTypeRef,
|
|
896
|
-
|
|
897
|
-
|
|
769
|
+
stream.label,
|
|
770
|
+
previousIncrementalDataRecord
|
|
898
771
|
);
|
|
899
772
|
index++;
|
|
900
773
|
continue;
|
|
@@ -907,8 +780,7 @@ function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, re
|
|
|
907
780
|
fieldGroup,
|
|
908
781
|
info,
|
|
909
782
|
itemPath,
|
|
910
|
-
incrementalDataRecord
|
|
911
|
-
deferMap
|
|
783
|
+
incrementalDataRecord
|
|
912
784
|
)) {
|
|
913
785
|
containsPromise = true;
|
|
914
786
|
}
|
|
@@ -916,52 +788,7 @@ function completeListValue(exeContext, returnTypeRef, fieldGroup, info, path, re
|
|
|
916
788
|
}
|
|
917
789
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
918
790
|
}
|
|
919
|
-
function
|
|
920
|
-
if (typeof path.key === "number") {
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
if (fieldGroup._streamUsage !== void 0) {
|
|
924
|
-
return fieldGroup._streamUsage;
|
|
925
|
-
}
|
|
926
|
-
const stream = getDirectiveValues(
|
|
927
|
-
exeContext.schemaFragment,
|
|
928
|
-
GraphQLStreamDirective,
|
|
929
|
-
fieldGroup.fields[0].node,
|
|
930
|
-
exeContext.variableValues
|
|
931
|
-
);
|
|
932
|
-
if (!stream) {
|
|
933
|
-
return;
|
|
934
|
-
}
|
|
935
|
-
if (stream.if === false) {
|
|
936
|
-
return;
|
|
937
|
-
}
|
|
938
|
-
invariant(
|
|
939
|
-
typeof stream.initialCount === "number",
|
|
940
|
-
"initialCount must be a number"
|
|
941
|
-
);
|
|
942
|
-
invariant(
|
|
943
|
-
stream.initialCount >= 0,
|
|
944
|
-
"initialCount must be a positive integer"
|
|
945
|
-
);
|
|
946
|
-
invariant(
|
|
947
|
-
exeContext.operation.operation !== "subscription",
|
|
948
|
-
"`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`."
|
|
949
|
-
);
|
|
950
|
-
const streamedFieldGroup = {
|
|
951
|
-
fields: fieldGroup.fields.map((fieldDetails) => ({
|
|
952
|
-
node: fieldDetails.node,
|
|
953
|
-
deferUsage: void 0
|
|
954
|
-
}))
|
|
955
|
-
};
|
|
956
|
-
const streamUsage = {
|
|
957
|
-
initialCount: stream.initialCount,
|
|
958
|
-
label: typeof stream.label === "string" ? stream.label : void 0,
|
|
959
|
-
fieldGroup: streamedFieldGroup
|
|
960
|
-
};
|
|
961
|
-
fieldGroup._streamUsage = streamUsage;
|
|
962
|
-
return streamUsage;
|
|
963
|
-
}
|
|
964
|
-
function completeListItemValue(item, completedResults, exeContext, itemTypeRef, fieldGroup, info, itemPath, incrementalDataRecord, deferMap) {
|
|
791
|
+
function completeListItemValue(item, completedResults, exeContext, itemTypeRef, fieldGroup, info, itemPath, incrementalDataRecord) {
|
|
965
792
|
if (isPromise(item)) {
|
|
966
793
|
completedResults.push(
|
|
967
794
|
completePromisedValue(
|
|
@@ -971,8 +798,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeRef,
|
|
|
971
798
|
info,
|
|
972
799
|
itemPath,
|
|
973
800
|
item,
|
|
974
|
-
incrementalDataRecord
|
|
975
|
-
deferMap
|
|
801
|
+
incrementalDataRecord
|
|
976
802
|
)
|
|
977
803
|
);
|
|
978
804
|
return true;
|
|
@@ -985,8 +811,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeRef,
|
|
|
985
811
|
info,
|
|
986
812
|
itemPath,
|
|
987
813
|
item,
|
|
988
|
-
incrementalDataRecord
|
|
989
|
-
deferMap
|
|
814
|
+
incrementalDataRecord
|
|
990
815
|
);
|
|
991
816
|
if (isPromise(completedItem)) {
|
|
992
817
|
completedResults.push(
|
|
@@ -999,10 +824,7 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeRef,
|
|
|
999
824
|
itemPath,
|
|
1000
825
|
incrementalDataRecord
|
|
1001
826
|
);
|
|
1002
|
-
exeContext
|
|
1003
|
-
itemPath,
|
|
1004
|
-
incrementalDataRecord
|
|
1005
|
-
);
|
|
827
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1006
828
|
return null;
|
|
1007
829
|
})
|
|
1008
830
|
);
|
|
@@ -1018,35 +840,61 @@ function completeListItemValue(item, completedResults, exeContext, itemTypeRef,
|
|
|
1018
840
|
itemPath,
|
|
1019
841
|
incrementalDataRecord
|
|
1020
842
|
);
|
|
1021
|
-
exeContext
|
|
843
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1022
844
|
completedResults.push(null);
|
|
1023
845
|
}
|
|
1024
846
|
return false;
|
|
1025
847
|
}
|
|
1026
|
-
function
|
|
848
|
+
function getStreamValues(exeContext, fieldGroup, path) {
|
|
849
|
+
if (typeof path.key === "number") {
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
const stream = getDirectiveValues(
|
|
853
|
+
exeContext,
|
|
854
|
+
GraphQLStreamDirective,
|
|
855
|
+
fieldGroup[0]
|
|
856
|
+
);
|
|
857
|
+
if (!stream) {
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
if (stream.if === false) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
invariant(
|
|
864
|
+
typeof stream.initialCount === "number",
|
|
865
|
+
"initialCount must be a number"
|
|
866
|
+
);
|
|
867
|
+
invariant(
|
|
868
|
+
stream.initialCount >= 0,
|
|
869
|
+
"initialCount must be a positive integer"
|
|
870
|
+
);
|
|
871
|
+
invariant(
|
|
872
|
+
exeContext.operation.operation !== "subscription",
|
|
873
|
+
"`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`."
|
|
874
|
+
);
|
|
875
|
+
return {
|
|
876
|
+
initialCount: stream.initialCount,
|
|
877
|
+
label: typeof stream.label === "string" ? stream.label : void 0
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
function completeAsyncIteratorValue(exeContext, itemTypeRef, fieldGroup, info, path, asyncIterator, incrementalDataRecord) {
|
|
1027
881
|
return __async(this, null, function* () {
|
|
1028
|
-
const
|
|
882
|
+
const stream = getStreamValues(exeContext, fieldGroup, path);
|
|
1029
883
|
let containsPromise = false;
|
|
1030
884
|
const completedResults = [];
|
|
1031
885
|
let index = 0;
|
|
1032
886
|
while (true) {
|
|
1033
|
-
if (
|
|
1034
|
-
const earlyReturn = asyncIterator.return;
|
|
1035
|
-
const streamRecord = new StreamRecord({
|
|
1036
|
-
label: streamUsage.label,
|
|
1037
|
-
path,
|
|
1038
|
-
earlyReturn: earlyReturn === void 0 ? void 0 : earlyReturn.bind(asyncIterator)
|
|
1039
|
-
});
|
|
887
|
+
if (stream && typeof stream.initialCount === "number" && index >= stream.initialCount) {
|
|
1040
888
|
executeStreamAsyncIterator(
|
|
1041
889
|
index,
|
|
1042
890
|
asyncIterator,
|
|
1043
891
|
exeContext,
|
|
1044
|
-
|
|
892
|
+
fieldGroup,
|
|
1045
893
|
info,
|
|
1046
894
|
itemTypeRef,
|
|
1047
895
|
path,
|
|
1048
|
-
|
|
1049
|
-
|
|
896
|
+
stream.label,
|
|
897
|
+
incrementalDataRecord
|
|
1050
898
|
);
|
|
1051
899
|
break;
|
|
1052
900
|
}
|
|
@@ -1058,7 +906,7 @@ function completeAsyncIteratorValue(exeContext, itemTypeRef, fieldGroup, info, p
|
|
|
1058
906
|
break;
|
|
1059
907
|
}
|
|
1060
908
|
} catch (rawError) {
|
|
1061
|
-
throw locatedError(rawError,
|
|
909
|
+
throw locatedError(rawError, fieldGroup, pathToArray(path));
|
|
1062
910
|
}
|
|
1063
911
|
if (completeListItemValue(
|
|
1064
912
|
iteration.value,
|
|
@@ -1068,8 +916,7 @@ function completeAsyncIteratorValue(exeContext, itemTypeRef, fieldGroup, info, p
|
|
|
1068
916
|
fieldGroup,
|
|
1069
917
|
info,
|
|
1070
918
|
itemPath,
|
|
1071
|
-
incrementalDataRecord
|
|
1072
|
-
deferMap
|
|
919
|
+
incrementalDataRecord
|
|
1073
920
|
)) {
|
|
1074
921
|
containsPromise = true;
|
|
1075
922
|
}
|
|
@@ -1087,7 +934,7 @@ function completeLeafValue(returnType, result) {
|
|
|
1087
934
|
}
|
|
1088
935
|
return serializedResult;
|
|
1089
936
|
}
|
|
1090
|
-
function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, path, result, incrementalDataRecord
|
|
937
|
+
function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, path, result, incrementalDataRecord) {
|
|
1091
938
|
var _a;
|
|
1092
939
|
const { schemaFragment } = exeContext;
|
|
1093
940
|
const resolveTypeFn = (_a = Resolvers.getAbstractTypeResolver(schemaFragment, returnTypeName)) != null ? _a : exeContext.typeResolver;
|
|
@@ -1118,8 +965,7 @@ function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, pat
|
|
|
1118
965
|
fieldGroup,
|
|
1119
966
|
path,
|
|
1120
967
|
result,
|
|
1121
|
-
incrementalDataRecord
|
|
1122
|
-
deferMap
|
|
968
|
+
incrementalDataRecord
|
|
1123
969
|
)
|
|
1124
970
|
);
|
|
1125
971
|
}
|
|
@@ -1129,15 +975,14 @@ function completeAbstractValue(exeContext, returnTypeName, fieldGroup, info, pat
|
|
|
1129
975
|
fieldGroup,
|
|
1130
976
|
path,
|
|
1131
977
|
result,
|
|
1132
|
-
incrementalDataRecord
|
|
1133
|
-
deferMap
|
|
978
|
+
incrementalDataRecord
|
|
1134
979
|
);
|
|
1135
980
|
}
|
|
1136
981
|
function ensureValidRuntimeType(runtimeTypeName, exeContext, returnTypeName, fieldGroup, info, result) {
|
|
1137
982
|
if (runtimeTypeName == null) {
|
|
1138
983
|
throw locatedError(
|
|
1139
984
|
`Abstract type "${returnTypeName}" must resolve to an Object type at runtime for field "${info.parentTypeName}.${info.fieldName}". Either the "${returnTypeName}" should provide a "__resolveType" resolver function or "${info.parentTypeName}.${info.fieldName}" should be an object with "__typename" property.`,
|
|
1140
|
-
|
|
985
|
+
fieldGroup
|
|
1141
986
|
);
|
|
1142
987
|
}
|
|
1143
988
|
if (typeof runtimeTypeName !== "string") {
|
|
@@ -1179,19 +1024,19 @@ function ensureValidRuntimeTypeImpl(runtimeTypeName, exeContext, returnTypeName,
|
|
|
1179
1024
|
if (!Definitions.isDefined(definitions, runtimeTypeName)) {
|
|
1180
1025
|
throw locatedError(
|
|
1181
1026
|
`Abstract type "${returnTypeName}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`,
|
|
1182
|
-
|
|
1027
|
+
fieldGroup
|
|
1183
1028
|
);
|
|
1184
1029
|
}
|
|
1185
1030
|
if (!Definitions.isObjectType(definitions, runtimeTypeName)) {
|
|
1186
1031
|
throw locatedError(
|
|
1187
1032
|
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
1188
|
-
|
|
1033
|
+
fieldGroup
|
|
1189
1034
|
);
|
|
1190
1035
|
}
|
|
1191
1036
|
if (!Definitions.isSubType(definitions, returnTypeName, runtimeTypeName)) {
|
|
1192
1037
|
throw locatedError(
|
|
1193
1038
|
`Runtime Object type "${runtimeTypeName}" is not a possible type for "${returnTypeName}".`,
|
|
1194
|
-
|
|
1039
|
+
fieldGroup
|
|
1195
1040
|
);
|
|
1196
1041
|
}
|
|
1197
1042
|
return runtimeTypeName;
|
|
@@ -1201,7 +1046,7 @@ function ensureValidRuntimeTypeImpl(runtimeTypeName, exeContext, returnTypeName,
|
|
|
1201
1046
|
if (Definitions.isDefined(definitions, runtimeTypeName) && !Definitions.isObjectType(definitions, runtimeTypeName)) {
|
|
1202
1047
|
throw locatedError(
|
|
1203
1048
|
`Abstract type "${returnTypeName}" was resolved to a non-object type "${runtimeTypeName}".`,
|
|
1204
|
-
|
|
1049
|
+
fieldGroup
|
|
1205
1050
|
);
|
|
1206
1051
|
}
|
|
1207
1052
|
Definitions.addInterfaceImplementation(
|
|
@@ -1213,104 +1058,41 @@ function ensureValidRuntimeTypeImpl(runtimeTypeName, exeContext, returnTypeName,
|
|
|
1213
1058
|
}
|
|
1214
1059
|
invariant(false, `${returnTypeName} is not an abstract type`);
|
|
1215
1060
|
}
|
|
1216
|
-
function completeObjectValue(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord
|
|
1061
|
+
function completeObjectValue(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
1217
1062
|
return collectAndExecuteSubfields(
|
|
1218
1063
|
exeContext,
|
|
1219
1064
|
returnTypeName,
|
|
1220
1065
|
fieldGroup,
|
|
1221
1066
|
path,
|
|
1222
1067
|
result,
|
|
1223
|
-
incrementalDataRecord
|
|
1224
|
-
deferMap
|
|
1225
|
-
);
|
|
1226
|
-
}
|
|
1227
|
-
function addNewDeferredFragments(incrementalPublisher, newDeferUsages, incrementalDataRecord, deferMap, path) {
|
|
1228
|
-
if (newDeferUsages.length === 0) {
|
|
1229
|
-
return deferMap != null ? deferMap : /* @__PURE__ */ new Map();
|
|
1230
|
-
}
|
|
1231
|
-
const newDeferMap = deferMap === void 0 ? /* @__PURE__ */ new Map() : new Map(deferMap);
|
|
1232
|
-
for (const newDeferUsage of newDeferUsages) {
|
|
1233
|
-
const parentDeferUsage = newDeferUsage.parentDeferUsage;
|
|
1234
|
-
const parent = parentDeferUsage === void 0 ? incrementalDataRecord : deferredFragmentRecordFromDeferUsage(parentDeferUsage, newDeferMap);
|
|
1235
|
-
const deferredFragmentRecord = new DeferredFragmentRecord({
|
|
1236
|
-
path,
|
|
1237
|
-
label: newDeferUsage.label
|
|
1238
|
-
});
|
|
1239
|
-
incrementalPublisher.reportNewDeferFragmentRecord(
|
|
1240
|
-
deferredFragmentRecord,
|
|
1241
|
-
parent
|
|
1242
|
-
);
|
|
1243
|
-
newDeferMap.set(newDeferUsage, deferredFragmentRecord);
|
|
1244
|
-
}
|
|
1245
|
-
return newDeferMap;
|
|
1246
|
-
}
|
|
1247
|
-
function deferredFragmentRecordFromDeferUsage(deferUsage, deferMap) {
|
|
1248
|
-
return deferMap.get(deferUsage);
|
|
1249
|
-
}
|
|
1250
|
-
function addNewDeferredGroupedFieldSets(incrementalPublisher, newGroupedFieldSetDetailsMap, deferMap, path) {
|
|
1251
|
-
const newDeferredGroupedFieldSetRecords = [];
|
|
1252
|
-
for (const [
|
|
1253
|
-
deferUsageSet,
|
|
1254
|
-
{ groupedFieldSet, shouldInitiateDefer }
|
|
1255
|
-
] of newGroupedFieldSetDetailsMap) {
|
|
1256
|
-
const deferredFragmentRecords = getDeferredFragmentRecords(
|
|
1257
|
-
deferUsageSet,
|
|
1258
|
-
deferMap
|
|
1259
|
-
);
|
|
1260
|
-
const deferredGroupedFieldSetRecord = new DeferredGroupedFieldSetRecord({
|
|
1261
|
-
path,
|
|
1262
|
-
deferredFragmentRecords,
|
|
1263
|
-
groupedFieldSet,
|
|
1264
|
-
shouldInitiateDefer
|
|
1265
|
-
});
|
|
1266
|
-
incrementalPublisher.reportNewDeferredGroupedFieldSetRecord(
|
|
1267
|
-
deferredGroupedFieldSetRecord
|
|
1268
|
-
);
|
|
1269
|
-
newDeferredGroupedFieldSetRecords.push(deferredGroupedFieldSetRecord);
|
|
1270
|
-
}
|
|
1271
|
-
return newDeferredGroupedFieldSetRecords;
|
|
1272
|
-
}
|
|
1273
|
-
function getDeferredFragmentRecords(deferUsages, deferMap) {
|
|
1274
|
-
return Array.from(deferUsages).map(
|
|
1275
|
-
(deferUsage) => deferredFragmentRecordFromDeferUsage(deferUsage, deferMap)
|
|
1068
|
+
incrementalDataRecord
|
|
1276
1069
|
);
|
|
1277
1070
|
}
|
|
1278
|
-
function collectAndExecuteSubfields(exeContext,
|
|
1279
|
-
const { groupedFieldSet
|
|
1280
|
-
const incrementalPublisher = exeContext.incrementalPublisher;
|
|
1281
|
-
const newDeferMap = addNewDeferredFragments(
|
|
1282
|
-
incrementalPublisher,
|
|
1283
|
-
newDeferUsages,
|
|
1284
|
-
incrementalDataRecord,
|
|
1285
|
-
deferMap,
|
|
1286
|
-
path
|
|
1287
|
-
);
|
|
1288
|
-
const newDeferredGroupedFieldSetRecords = addNewDeferredGroupedFieldSets(
|
|
1289
|
-
incrementalPublisher,
|
|
1290
|
-
newGroupedFieldSetDetailsMap,
|
|
1291
|
-
newDeferMap,
|
|
1292
|
-
path
|
|
1293
|
-
);
|
|
1071
|
+
function collectAndExecuteSubfields(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
1072
|
+
const { groupedFieldSet: subGroupedFieldSet, patches: subPatches } = collectSubfields(exeContext, { name: returnTypeName }, fieldGroup);
|
|
1294
1073
|
const subFields = executeFields(
|
|
1295
1074
|
exeContext,
|
|
1296
|
-
|
|
1297
|
-
result,
|
|
1298
|
-
path,
|
|
1299
|
-
groupedFieldSet,
|
|
1300
|
-
incrementalDataRecord,
|
|
1301
|
-
newDeferMap
|
|
1302
|
-
);
|
|
1303
|
-
executeDeferredGroupedFieldSets(
|
|
1304
|
-
exeContext,
|
|
1305
|
-
returnType,
|
|
1075
|
+
returnTypeName,
|
|
1306
1076
|
result,
|
|
1307
1077
|
path,
|
|
1308
|
-
|
|
1309
|
-
|
|
1078
|
+
subGroupedFieldSet,
|
|
1079
|
+
incrementalDataRecord
|
|
1310
1080
|
);
|
|
1081
|
+
for (const subPatch of subPatches) {
|
|
1082
|
+
const { label, groupedFieldSet: subPatchGroupedFieldSet } = subPatch;
|
|
1083
|
+
executeDeferredFragment(
|
|
1084
|
+
exeContext,
|
|
1085
|
+
returnTypeName,
|
|
1086
|
+
result,
|
|
1087
|
+
subPatchGroupedFieldSet,
|
|
1088
|
+
label,
|
|
1089
|
+
path,
|
|
1090
|
+
incrementalDataRecord
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1311
1093
|
return subFields;
|
|
1312
1094
|
}
|
|
1313
|
-
function invokeBeforeFieldResolveHook(resolveInfo, exeContext
|
|
1095
|
+
function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
1314
1096
|
var _a;
|
|
1315
1097
|
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.beforeFieldResolve;
|
|
1316
1098
|
if (!hook) {
|
|
@@ -1328,15 +1110,12 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext, incrementalDataRe
|
|
|
1328
1110
|
resolveInfo.path,
|
|
1329
1111
|
"Unexpected error in beforeFieldResolve hook"
|
|
1330
1112
|
);
|
|
1331
|
-
exeContext.
|
|
1332
|
-
incrementalDataRecord,
|
|
1333
|
-
error
|
|
1334
|
-
);
|
|
1113
|
+
exeContext.errors.push(error);
|
|
1335
1114
|
}
|
|
1336
1115
|
}
|
|
1337
1116
|
);
|
|
1338
1117
|
}
|
|
1339
|
-
function invokeAfterFieldResolveHook(resolveInfo, exeContext,
|
|
1118
|
+
function invokeAfterFieldResolveHook(resolveInfo, exeContext, result, error) {
|
|
1340
1119
|
var _a;
|
|
1341
1120
|
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.afterFieldResolve;
|
|
1342
1121
|
if (!hook) {
|
|
@@ -1356,15 +1135,12 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, incrementalDataRec
|
|
|
1356
1135
|
resolveInfo.path,
|
|
1357
1136
|
"Unexpected error in afterFieldResolve hook"
|
|
1358
1137
|
);
|
|
1359
|
-
exeContext.
|
|
1360
|
-
incrementalDataRecord,
|
|
1361
|
-
error2
|
|
1362
|
-
);
|
|
1138
|
+
exeContext.errors.push(error2);
|
|
1363
1139
|
}
|
|
1364
1140
|
}
|
|
1365
1141
|
);
|
|
1366
1142
|
}
|
|
1367
|
-
function invokeAfterFieldCompleteHook(resolveInfo, exeContext,
|
|
1143
|
+
function invokeAfterFieldCompleteHook(resolveInfo, exeContext, result, error) {
|
|
1368
1144
|
var _a;
|
|
1369
1145
|
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.afterFieldComplete;
|
|
1370
1146
|
if (!hook) {
|
|
@@ -1384,10 +1160,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, incrementalDataRe
|
|
|
1384
1160
|
resolveInfo.path,
|
|
1385
1161
|
"Unexpected error in afterFieldComplete hook"
|
|
1386
1162
|
);
|
|
1387
|
-
exeContext.
|
|
1388
|
-
incrementalDataRecord,
|
|
1389
|
-
error2
|
|
1390
|
-
);
|
|
1163
|
+
exeContext.errors.push(error2);
|
|
1391
1164
|
}
|
|
1392
1165
|
}
|
|
1393
1166
|
);
|
|
@@ -1441,215 +1214,153 @@ function getOperationRootTypeName(operation) {
|
|
|
1441
1214
|
);
|
|
1442
1215
|
}
|
|
1443
1216
|
}
|
|
1444
|
-
function
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
if (deferredGroupedFieldSetRecord.shouldInitiateDefer) {
|
|
1453
|
-
Promise.resolve().then(
|
|
1454
|
-
() => executeDeferredGroupedFieldSet(
|
|
1455
|
-
exeContext,
|
|
1456
|
-
parentTypeName,
|
|
1457
|
-
sourceValue,
|
|
1458
|
-
path,
|
|
1459
|
-
deferredGroupedFieldSetRecord,
|
|
1460
|
-
deferMap
|
|
1461
|
-
)
|
|
1462
|
-
);
|
|
1463
|
-
continue;
|
|
1464
|
-
}
|
|
1465
|
-
executeDeferredGroupedFieldSet(
|
|
1466
|
-
exeContext,
|
|
1467
|
-
parentTypeName,
|
|
1468
|
-
sourceValue,
|
|
1469
|
-
path,
|
|
1470
|
-
deferredGroupedFieldSetRecord,
|
|
1471
|
-
deferMap
|
|
1472
|
-
);
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
function executeDeferredGroupedFieldSet(exeContext, parentTypeName, sourceValue, path, deferredGroupedFieldSetRecord, deferMap) {
|
|
1217
|
+
function executeDeferredFragment(exeContext, parentTypeName, sourceValue, fields, label, path, parentContext) {
|
|
1218
|
+
const incrementalDataRecord = new DeferredFragmentRecord({
|
|
1219
|
+
label,
|
|
1220
|
+
path,
|
|
1221
|
+
parentContext,
|
|
1222
|
+
exeContext
|
|
1223
|
+
});
|
|
1224
|
+
let promiseOrData;
|
|
1476
1225
|
try {
|
|
1477
|
-
|
|
1226
|
+
promiseOrData = executeFields(
|
|
1478
1227
|
exeContext,
|
|
1479
1228
|
parentTypeName,
|
|
1480
1229
|
sourceValue,
|
|
1481
1230
|
path,
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
deferMap
|
|
1231
|
+
fields,
|
|
1232
|
+
incrementalDataRecord
|
|
1485
1233
|
);
|
|
1486
|
-
if (isPromise(
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
),
|
|
1492
|
-
(error) => exeContext.incrementalPublisher.markErroredDeferredGroupedFieldSet(
|
|
1493
|
-
deferredGroupedFieldSetRecord,
|
|
1494
|
-
error
|
|
1495
|
-
)
|
|
1496
|
-
);
|
|
1497
|
-
return;
|
|
1234
|
+
if (isPromise(promiseOrData)) {
|
|
1235
|
+
promiseOrData = promiseOrData.then(null, (e) => {
|
|
1236
|
+
incrementalDataRecord.errors.push(e);
|
|
1237
|
+
return null;
|
|
1238
|
+
});
|
|
1498
1239
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
);
|
|
1503
|
-
} catch (error) {
|
|
1504
|
-
exeContext.incrementalPublisher.markErroredDeferredGroupedFieldSet(
|
|
1505
|
-
deferredGroupedFieldSetRecord,
|
|
1506
|
-
error
|
|
1507
|
-
);
|
|
1240
|
+
} catch (e) {
|
|
1241
|
+
incrementalDataRecord.errors.push(e);
|
|
1242
|
+
promiseOrData = null;
|
|
1508
1243
|
}
|
|
1244
|
+
incrementalDataRecord.addData(promiseOrData);
|
|
1509
1245
|
}
|
|
1510
|
-
function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info,
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1246
|
+
function executeStreamField(path, itemPath, item, exeContext, fieldGroup, info, itemTypeRef, label, parentContext) {
|
|
1247
|
+
const incrementalDataRecord = new StreamItemsRecord({
|
|
1248
|
+
label,
|
|
1249
|
+
path: itemPath,
|
|
1250
|
+
parentContext,
|
|
1251
|
+
exeContext
|
|
1515
1252
|
});
|
|
1516
|
-
incrementalPublisher.reportNewStreamItemsRecord(
|
|
1517
|
-
streamItemsRecord,
|
|
1518
|
-
incrementalDataRecord
|
|
1519
|
-
);
|
|
1520
1253
|
if (isPromise(item)) {
|
|
1521
|
-
completePromisedValue(
|
|
1254
|
+
const completedItems = completePromisedValue(
|
|
1522
1255
|
exeContext,
|
|
1523
|
-
|
|
1256
|
+
itemTypeRef,
|
|
1524
1257
|
fieldGroup,
|
|
1525
1258
|
info,
|
|
1526
1259
|
itemPath,
|
|
1527
1260
|
item,
|
|
1528
|
-
|
|
1529
|
-
/* @__PURE__ */ new Map()
|
|
1261
|
+
incrementalDataRecord
|
|
1530
1262
|
).then(
|
|
1531
|
-
(value) =>
|
|
1532
|
-
value
|
|
1533
|
-
]),
|
|
1263
|
+
(value) => [value],
|
|
1534
1264
|
(error) => {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
error
|
|
1539
|
-
);
|
|
1265
|
+
incrementalDataRecord.errors.push(error);
|
|
1266
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1267
|
+
return null;
|
|
1540
1268
|
}
|
|
1541
1269
|
);
|
|
1542
|
-
|
|
1270
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1271
|
+
return incrementalDataRecord;
|
|
1543
1272
|
}
|
|
1544
1273
|
let completedItem;
|
|
1545
1274
|
try {
|
|
1546
1275
|
try {
|
|
1547
1276
|
completedItem = completeValue(
|
|
1548
1277
|
exeContext,
|
|
1549
|
-
|
|
1278
|
+
itemTypeRef,
|
|
1550
1279
|
fieldGroup,
|
|
1551
1280
|
info,
|
|
1552
1281
|
itemPath,
|
|
1553
1282
|
item,
|
|
1554
|
-
|
|
1555
|
-
/* @__PURE__ */ new Map()
|
|
1283
|
+
incrementalDataRecord
|
|
1556
1284
|
);
|
|
1557
1285
|
} catch (rawError) {
|
|
1558
1286
|
handleFieldError(
|
|
1559
1287
|
rawError,
|
|
1560
1288
|
exeContext,
|
|
1561
|
-
|
|
1289
|
+
itemTypeRef,
|
|
1562
1290
|
fieldGroup,
|
|
1563
1291
|
itemPath,
|
|
1564
|
-
|
|
1292
|
+
incrementalDataRecord
|
|
1565
1293
|
);
|
|
1566
1294
|
completedItem = null;
|
|
1567
|
-
|
|
1295
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1568
1296
|
}
|
|
1569
1297
|
} catch (error) {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
);
|
|
1575
|
-
return streamItemsRecord;
|
|
1298
|
+
incrementalDataRecord.errors.push(error);
|
|
1299
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1300
|
+
incrementalDataRecord.addItems(null);
|
|
1301
|
+
return incrementalDataRecord;
|
|
1576
1302
|
}
|
|
1577
1303
|
if (isPromise(completedItem)) {
|
|
1578
|
-
completedItem.then(void 0, (rawError) => {
|
|
1304
|
+
const completedItems = completedItem.then(void 0, (rawError) => {
|
|
1579
1305
|
handleFieldError(
|
|
1580
1306
|
rawError,
|
|
1581
1307
|
exeContext,
|
|
1582
|
-
|
|
1308
|
+
itemTypeRef,
|
|
1583
1309
|
fieldGroup,
|
|
1584
1310
|
itemPath,
|
|
1585
|
-
|
|
1311
|
+
incrementalDataRecord
|
|
1586
1312
|
);
|
|
1587
|
-
|
|
1313
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1588
1314
|
return null;
|
|
1589
1315
|
}).then(
|
|
1590
|
-
(value) =>
|
|
1591
|
-
value
|
|
1592
|
-
]),
|
|
1316
|
+
(value) => [value],
|
|
1593
1317
|
(error) => {
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
error
|
|
1598
|
-
);
|
|
1318
|
+
incrementalDataRecord.errors.push(error);
|
|
1319
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1320
|
+
return null;
|
|
1599
1321
|
}
|
|
1600
1322
|
);
|
|
1601
|
-
|
|
1323
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1324
|
+
return incrementalDataRecord;
|
|
1602
1325
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
]);
|
|
1606
|
-
return streamItemsRecord;
|
|
1326
|
+
incrementalDataRecord.addItems([completedItem]);
|
|
1327
|
+
return incrementalDataRecord;
|
|
1607
1328
|
}
|
|
1608
|
-
function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, info,
|
|
1329
|
+
function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, info, itemTypeRef, incrementalDataRecord, path, itemPath) {
|
|
1609
1330
|
return __async(this, null, function* () {
|
|
1610
1331
|
let item;
|
|
1611
1332
|
try {
|
|
1612
|
-
const
|
|
1613
|
-
if (
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
if (iteration.done) {
|
|
1617
|
-
exeContext.incrementalPublisher.setIsCompletedAsyncIterator(
|
|
1618
|
-
streamItemsRecord
|
|
1619
|
-
);
|
|
1620
|
-
return { done: true, value: void 0 };
|
|
1333
|
+
const { value, done } = yield asyncIterator.next();
|
|
1334
|
+
if (done) {
|
|
1335
|
+
incrementalDataRecord.setIsCompletedAsyncIterator();
|
|
1336
|
+
return { done, value: void 0 };
|
|
1621
1337
|
}
|
|
1622
|
-
item =
|
|
1338
|
+
item = value;
|
|
1623
1339
|
} catch (rawError) {
|
|
1624
|
-
throw locatedError(
|
|
1625
|
-
rawError,
|
|
1626
|
-
toNodes(fieldGroup),
|
|
1627
|
-
streamItemsRecord.streamRecord.path
|
|
1628
|
-
);
|
|
1340
|
+
throw locatedError(rawError, fieldGroup, pathToArray(path));
|
|
1629
1341
|
}
|
|
1630
1342
|
let completedItem;
|
|
1631
1343
|
try {
|
|
1632
1344
|
completedItem = completeValue(
|
|
1633
1345
|
exeContext,
|
|
1634
|
-
|
|
1346
|
+
itemTypeRef,
|
|
1635
1347
|
fieldGroup,
|
|
1636
1348
|
info,
|
|
1637
1349
|
itemPath,
|
|
1638
1350
|
item,
|
|
1639
|
-
|
|
1640
|
-
/* @__PURE__ */ new Map()
|
|
1351
|
+
incrementalDataRecord
|
|
1641
1352
|
);
|
|
1642
1353
|
if (isPromise(completedItem)) {
|
|
1643
1354
|
completedItem = completedItem.then(void 0, (rawError) => {
|
|
1644
1355
|
handleFieldError(
|
|
1645
1356
|
rawError,
|
|
1646
1357
|
exeContext,
|
|
1647
|
-
|
|
1358
|
+
itemTypeRef,
|
|
1648
1359
|
fieldGroup,
|
|
1649
1360
|
itemPath,
|
|
1650
|
-
|
|
1361
|
+
incrementalDataRecord
|
|
1651
1362
|
);
|
|
1652
|
-
exeContext
|
|
1363
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1653
1364
|
return null;
|
|
1654
1365
|
});
|
|
1655
1366
|
}
|
|
@@ -1658,31 +1369,29 @@ function executeStreamAsyncIteratorItem(asyncIterator, exeContext, fieldGroup, i
|
|
|
1658
1369
|
handleFieldError(
|
|
1659
1370
|
rawError,
|
|
1660
1371
|
exeContext,
|
|
1661
|
-
|
|
1372
|
+
itemTypeRef,
|
|
1662
1373
|
fieldGroup,
|
|
1663
1374
|
itemPath,
|
|
1664
|
-
|
|
1375
|
+
incrementalDataRecord
|
|
1665
1376
|
);
|
|
1666
|
-
exeContext
|
|
1377
|
+
filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);
|
|
1667
1378
|
return { done: false, value: null };
|
|
1668
1379
|
}
|
|
1669
1380
|
});
|
|
1670
1381
|
}
|
|
1671
|
-
function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fieldGroup, info,
|
|
1382
|
+
function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fieldGroup, info, itemTypeRef, path, label, parentContext) {
|
|
1672
1383
|
return __async(this, null, function* () {
|
|
1673
|
-
const incrementalPublisher = exeContext.incrementalPublisher;
|
|
1674
1384
|
let index = initialIndex;
|
|
1675
|
-
let
|
|
1385
|
+
let previousIncrementalDataRecord = parentContext != null ? parentContext : void 0;
|
|
1676
1386
|
while (true) {
|
|
1677
1387
|
const itemPath = addPath(path, index, void 0);
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1680
|
-
path: itemPath
|
|
1388
|
+
const incrementalDataRecord = new StreamItemsRecord({
|
|
1389
|
+
label,
|
|
1390
|
+
path: itemPath,
|
|
1391
|
+
parentContext: previousIncrementalDataRecord,
|
|
1392
|
+
asyncIterator,
|
|
1393
|
+
exeContext
|
|
1681
1394
|
});
|
|
1682
|
-
incrementalPublisher.reportNewStreamItemsRecord(
|
|
1683
|
-
streamItemsRecord,
|
|
1684
|
-
currentIncrementalDataRecord
|
|
1685
|
-
);
|
|
1686
1395
|
let iteration;
|
|
1687
1396
|
try {
|
|
1688
1397
|
iteration = yield executeStreamAsyncIteratorItem(
|
|
@@ -1690,47 +1399,223 @@ function executeStreamAsyncIterator(initialIndex, asyncIterator, exeContext, fie
|
|
|
1690
1399
|
exeContext,
|
|
1691
1400
|
fieldGroup,
|
|
1692
1401
|
info,
|
|
1693
|
-
|
|
1694
|
-
|
|
1402
|
+
itemTypeRef,
|
|
1403
|
+
incrementalDataRecord,
|
|
1404
|
+
path,
|
|
1695
1405
|
itemPath
|
|
1696
1406
|
);
|
|
1697
1407
|
} catch (error) {
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1408
|
+
incrementalDataRecord.errors.push(error);
|
|
1409
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1410
|
+
incrementalDataRecord.addItems(null);
|
|
1411
|
+
if (asyncIterator == null ? void 0 : asyncIterator.return) {
|
|
1412
|
+
asyncIterator.return().catch(() => {
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1703
1415
|
return;
|
|
1704
1416
|
}
|
|
1705
1417
|
const { done, value: completedItem } = iteration;
|
|
1418
|
+
let completedItems;
|
|
1706
1419
|
if (isPromise(completedItem)) {
|
|
1707
|
-
completedItem.then(
|
|
1708
|
-
(value) =>
|
|
1709
|
-
value
|
|
1710
|
-
]),
|
|
1420
|
+
completedItems = completedItem.then(
|
|
1421
|
+
(value) => [value],
|
|
1711
1422
|
(error) => {
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
error
|
|
1716
|
-
);
|
|
1423
|
+
incrementalDataRecord.errors.push(error);
|
|
1424
|
+
filterSubsequentPayloads(exeContext, path, incrementalDataRecord);
|
|
1425
|
+
return null;
|
|
1717
1426
|
}
|
|
1718
1427
|
);
|
|
1719
1428
|
} else {
|
|
1720
|
-
|
|
1721
|
-
completedItem
|
|
1722
|
-
]);
|
|
1429
|
+
completedItems = [completedItem];
|
|
1723
1430
|
}
|
|
1431
|
+
incrementalDataRecord.addItems(completedItems);
|
|
1724
1432
|
if (done) {
|
|
1725
1433
|
break;
|
|
1726
1434
|
}
|
|
1727
|
-
|
|
1435
|
+
previousIncrementalDataRecord = incrementalDataRecord;
|
|
1728
1436
|
index++;
|
|
1729
1437
|
}
|
|
1730
1438
|
});
|
|
1731
1439
|
}
|
|
1732
|
-
function
|
|
1733
|
-
|
|
1440
|
+
function filterSubsequentPayloads(exeContext, nullPath, currentIncrementalDataRecord) {
|
|
1441
|
+
const nullPathArray = pathToArray(nullPath);
|
|
1442
|
+
exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {
|
|
1443
|
+
var _a;
|
|
1444
|
+
if (incrementalDataRecord === currentIncrementalDataRecord) {
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
for (let i = 0; i < nullPathArray.length; i++) {
|
|
1448
|
+
if (incrementalDataRecord.path[i] !== nullPathArray[i]) {
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
if (isStreamItemsRecord(incrementalDataRecord) && ((_a = incrementalDataRecord.asyncIterator) == null ? void 0 : _a.return)) {
|
|
1453
|
+
incrementalDataRecord.asyncIterator.return().catch(() => {
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
exeContext.subsequentPayloads.delete(incrementalDataRecord);
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
function getCompletedIncrementalResults(exeContext) {
|
|
1460
|
+
const incrementalResults = [];
|
|
1461
|
+
for (const incrementalDataRecord of exeContext.subsequentPayloads) {
|
|
1462
|
+
const incrementalResult = {};
|
|
1463
|
+
if (!incrementalDataRecord.isCompleted) {
|
|
1464
|
+
continue;
|
|
1465
|
+
}
|
|
1466
|
+
exeContext.subsequentPayloads.delete(incrementalDataRecord);
|
|
1467
|
+
if (isStreamItemsRecord(incrementalDataRecord)) {
|
|
1468
|
+
const items = incrementalDataRecord.items;
|
|
1469
|
+
if (incrementalDataRecord.isCompletedAsyncIterator) {
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
incrementalResult.items = items;
|
|
1473
|
+
} else {
|
|
1474
|
+
const data = incrementalDataRecord.data;
|
|
1475
|
+
incrementalResult.data = data != null ? data : null;
|
|
1476
|
+
}
|
|
1477
|
+
incrementalResult.path = incrementalDataRecord.path;
|
|
1478
|
+
if (incrementalDataRecord.label != null) {
|
|
1479
|
+
incrementalResult.label = incrementalDataRecord.label;
|
|
1480
|
+
}
|
|
1481
|
+
if (incrementalDataRecord.errors.length > 0) {
|
|
1482
|
+
incrementalResult.errors = incrementalDataRecord.errors;
|
|
1483
|
+
}
|
|
1484
|
+
incrementalResults.push(incrementalResult);
|
|
1485
|
+
}
|
|
1486
|
+
return incrementalResults;
|
|
1487
|
+
}
|
|
1488
|
+
function yieldSubsequentPayloads(exeContext) {
|
|
1489
|
+
let isDone = false;
|
|
1490
|
+
function next() {
|
|
1491
|
+
return __async(this, null, function* () {
|
|
1492
|
+
if (isDone) {
|
|
1493
|
+
return { value: void 0, done: true };
|
|
1494
|
+
}
|
|
1495
|
+
yield Promise.race(
|
|
1496
|
+
Array.from(exeContext.subsequentPayloads).map((p) => p.promise)
|
|
1497
|
+
);
|
|
1498
|
+
if (isDone) {
|
|
1499
|
+
return { value: void 0, done: true };
|
|
1500
|
+
}
|
|
1501
|
+
const incremental = getCompletedIncrementalResults(exeContext);
|
|
1502
|
+
const hasNext = exeContext.subsequentPayloads.size > 0;
|
|
1503
|
+
if (!incremental.length && hasNext) {
|
|
1504
|
+
return next();
|
|
1505
|
+
}
|
|
1506
|
+
if (!hasNext) {
|
|
1507
|
+
isDone = true;
|
|
1508
|
+
}
|
|
1509
|
+
return {
|
|
1510
|
+
value: incremental.length ? { incremental, hasNext } : { hasNext },
|
|
1511
|
+
done: false
|
|
1512
|
+
};
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
function returnStreamIterators() {
|
|
1516
|
+
const promises = [];
|
|
1517
|
+
exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {
|
|
1518
|
+
var _a2;
|
|
1519
|
+
if (isStreamItemsRecord(incrementalDataRecord) && ((_a2 = incrementalDataRecord.asyncIterator) == null ? void 0 : _a2.return)) {
|
|
1520
|
+
promises.push(incrementalDataRecord.asyncIterator.return());
|
|
1521
|
+
}
|
|
1522
|
+
});
|
|
1523
|
+
return Promise.all(promises);
|
|
1524
|
+
}
|
|
1525
|
+
return {
|
|
1526
|
+
[Symbol.asyncIterator]() {
|
|
1527
|
+
return this;
|
|
1528
|
+
},
|
|
1529
|
+
next,
|
|
1530
|
+
return() {
|
|
1531
|
+
return __async(this, null, function* () {
|
|
1532
|
+
yield returnStreamIterators();
|
|
1533
|
+
isDone = true;
|
|
1534
|
+
return { value: void 0, done: true };
|
|
1535
|
+
});
|
|
1536
|
+
},
|
|
1537
|
+
throw(error) {
|
|
1538
|
+
return __async(this, null, function* () {
|
|
1539
|
+
yield returnStreamIterators();
|
|
1540
|
+
isDone = true;
|
|
1541
|
+
return Promise.reject(error);
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
function isStreamItemsRecord(incrementalDataRecord) {
|
|
1547
|
+
return incrementalDataRecord.type === "stream";
|
|
1548
|
+
}
|
|
1549
|
+
var DeferredFragmentRecord = class {
|
|
1550
|
+
constructor(opts) {
|
|
1551
|
+
this.type = "defer";
|
|
1552
|
+
this.label = opts.label;
|
|
1553
|
+
this.path = pathToArray(opts.path);
|
|
1554
|
+
this.parentContext = opts.parentContext;
|
|
1555
|
+
this.errors = [];
|
|
1556
|
+
this._exeContext = opts.exeContext;
|
|
1557
|
+
this._exeContext.subsequentPayloads.add(this);
|
|
1558
|
+
this.isCompleted = false;
|
|
1559
|
+
this.data = null;
|
|
1560
|
+
this.promise = new Promise((resolve) => {
|
|
1561
|
+
this._resolve = (promiseOrValue) => {
|
|
1562
|
+
resolve(promiseOrValue);
|
|
1563
|
+
};
|
|
1564
|
+
}).then((data) => {
|
|
1565
|
+
this.data = data;
|
|
1566
|
+
this.isCompleted = true;
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
addData(data) {
|
|
1570
|
+
var _a, _b, _c;
|
|
1571
|
+
const parentData = (_a = this.parentContext) == null ? void 0 : _a.promise;
|
|
1572
|
+
if (parentData) {
|
|
1573
|
+
(_b = this._resolve) == null ? void 0 : _b.call(this, parentData.then(() => data));
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
(_c = this._resolve) == null ? void 0 : _c.call(this, data);
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
var StreamItemsRecord = class {
|
|
1580
|
+
constructor(opts) {
|
|
1581
|
+
this.type = "stream";
|
|
1582
|
+
this.items = null;
|
|
1583
|
+
this.label = opts.label;
|
|
1584
|
+
this.path = pathToArray(opts.path);
|
|
1585
|
+
this.parentContext = opts.parentContext;
|
|
1586
|
+
this.asyncIterator = opts.asyncIterator;
|
|
1587
|
+
this.errors = [];
|
|
1588
|
+
this._exeContext = opts.exeContext;
|
|
1589
|
+
this._exeContext.subsequentPayloads.add(this);
|
|
1590
|
+
this.isCompleted = false;
|
|
1591
|
+
this.items = null;
|
|
1592
|
+
this.promise = new Promise((resolve) => {
|
|
1593
|
+
this._resolve = (promiseOrValue) => {
|
|
1594
|
+
resolve(promiseOrValue);
|
|
1595
|
+
};
|
|
1596
|
+
}).then((items) => {
|
|
1597
|
+
this.items = items;
|
|
1598
|
+
this.isCompleted = true;
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
addItems(items) {
|
|
1602
|
+
var _a, _b, _c;
|
|
1603
|
+
const parentData = (_a = this.parentContext) == null ? void 0 : _a.promise;
|
|
1604
|
+
if (parentData) {
|
|
1605
|
+
(_b = this._resolve) == null ? void 0 : _b.call(this, parentData.then(() => items));
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
(_c = this._resolve) == null ? void 0 : _c.call(this, items);
|
|
1609
|
+
}
|
|
1610
|
+
setIsCompletedAsyncIterator() {
|
|
1611
|
+
this.isCompletedAsyncIterator = true;
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
function isIncrementalExecutionResult(result) {
|
|
1615
|
+
return "initialResult" in result;
|
|
1616
|
+
}
|
|
1617
|
+
function isTotalExecutionResult(result) {
|
|
1618
|
+
return !("initialResult" in result);
|
|
1734
1619
|
}
|
|
1735
1620
|
export {
|
|
1736
1621
|
assertValidExecutionArguments,
|