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