@graphitation/supermassive 3.18.1-canary.2 → 4.0.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 +25 -1
- package/README.md +9 -0
- package/lib/executeWithSchema.d.ts +1 -1
- package/lib/executeWithSchema.d.ts.map +1 -1
- package/lib/executeWithSchema.js +2 -6
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +2 -6
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +0 -2
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +7 -86
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +7 -86
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/types.d.ts +0 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
collectSubfields as _collectSubfields
|
|
10
10
|
} from "./collectFields.mjs";
|
|
11
11
|
import { devAssert } from "./jsutils/devAssert.mjs";
|
|
12
|
-
import { getObjectAtPath } from "./jsutils/getObjectAtPath.mjs";
|
|
13
12
|
import { inspect } from "./jsutils/inspect.mjs";
|
|
14
13
|
import { invariant } from "./jsutils/invariant.mjs";
|
|
15
14
|
import { isIterableObject } from "./jsutils/isIterableObject.mjs";
|
|
@@ -40,7 +39,6 @@ import * as Resolvers from "./schema/resolvers.mjs";
|
|
|
40
39
|
var collectSubfields = memoize3(
|
|
41
40
|
(exeContext, returnTypeName, fieldGroup) => _collectSubfields(exeContext, returnTypeName.name, fieldGroup)
|
|
42
41
|
);
|
|
43
|
-
var SUBSEQUENT_PAYLOAD_BATCH_INTERVAL_MS = 5;
|
|
44
42
|
function executeWithoutSchema(args) {
|
|
45
43
|
const exeContext = buildExecutionContext(args);
|
|
46
44
|
if (!("schemaFragment" in exeContext)) {
|
|
@@ -72,9 +70,7 @@ function buildExecutionContext(args) {
|
|
|
72
70
|
subscribeFieldResolver,
|
|
73
71
|
fieldExecutionHooks,
|
|
74
72
|
enablePerEventContext,
|
|
75
|
-
enableEarlyExecution
|
|
76
|
-
enableDeferredMerge,
|
|
77
|
-
enableIncrementalPayloadBatching
|
|
73
|
+
enableEarlyExecution
|
|
78
74
|
} = args;
|
|
79
75
|
assertValidExecutionArguments(document, variableValues);
|
|
80
76
|
let operation;
|
|
@@ -133,9 +129,7 @@ function buildExecutionContext(args) {
|
|
|
133
129
|
fieldExecutionHooks,
|
|
134
130
|
subsequentPayloads: /* @__PURE__ */ new Set(),
|
|
135
131
|
enablePerEventContext: enablePerEventContext != null ? enablePerEventContext : true,
|
|
136
|
-
enableEarlyExecution: enableEarlyExecution != null ? enableEarlyExecution : false
|
|
137
|
-
enableDeferredMerge: enableDeferredMerge != null ? enableDeferredMerge : false,
|
|
138
|
-
enableIncrementalPayloadBatching: enableIncrementalPayloadBatching != null ? enableIncrementalPayloadBatching : false
|
|
132
|
+
enableEarlyExecution: enableEarlyExecution != null ? enableEarlyExecution : false
|
|
139
133
|
};
|
|
140
134
|
}
|
|
141
135
|
function buildPerEventExecutionContext(exeContext, payload) {
|
|
@@ -236,7 +230,7 @@ function executeOperation(exeContext) {
|
|
|
236
230
|
return buildResponse(exeContext, null);
|
|
237
231
|
}
|
|
238
232
|
}
|
|
239
|
-
function buildResponse(exeContext, data
|
|
233
|
+
function buildResponse(exeContext, data) {
|
|
240
234
|
var _a, _b;
|
|
241
235
|
if (isPromise(data)) {
|
|
242
236
|
return data.then(
|
|
@@ -249,14 +243,6 @@ function buildResponse(exeContext, data, didWaitForDeferredMerge) {
|
|
|
249
243
|
}
|
|
250
244
|
const hooks = exeContext.fieldExecutionHooks;
|
|
251
245
|
try {
|
|
252
|
-
if (exeContext.enableDeferredMerge) {
|
|
253
|
-
if (shouldWaitForDeferredMerge(exeContext, data, didWaitForDeferredMerge)) {
|
|
254
|
-
return waitForNextTick().then(
|
|
255
|
-
() => buildResponse(exeContext, data, true)
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
includeCompletedDeferredFragmentsInResult(exeContext, data);
|
|
259
|
-
}
|
|
260
246
|
const initialResult = exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
261
247
|
if (exeContext.subsequentPayloads.size > 0) {
|
|
262
248
|
return {
|
|
@@ -286,25 +272,6 @@ function buildResponse(exeContext, data, didWaitForDeferredMerge) {
|
|
|
286
272
|
return buildResponse(exeContext, null);
|
|
287
273
|
}
|
|
288
274
|
}
|
|
289
|
-
function shouldWaitForDeferredMerge(exeContext, result, didWaitForDeferredMerge) {
|
|
290
|
-
if (didWaitForDeferredMerge || result == null) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
let hasDeferredFragment = false;
|
|
294
|
-
for (const incrementalDataRecord of exeContext.subsequentPayloads) {
|
|
295
|
-
if (!isDeferredFragmentRecord(incrementalDataRecord)) {
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
if (incrementalDataRecord.isCompleted) {
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
hasDeferredFragment = true;
|
|
302
|
-
}
|
|
303
|
-
return hasDeferredFragment;
|
|
304
|
-
}
|
|
305
|
-
function waitForNextTick() {
|
|
306
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
307
|
-
}
|
|
308
275
|
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, groupedFieldSet, patches) {
|
|
309
276
|
if (exeContext.enableEarlyExecution) {
|
|
310
277
|
startExecutingPatches(
|
|
@@ -406,27 +373,6 @@ function startExecutingPatches(exeContext, parentTypeName, sourceValue, path, pa
|
|
|
406
373
|
);
|
|
407
374
|
}
|
|
408
375
|
}
|
|
409
|
-
function includeCompletedDeferredFragmentsInResult(exeContext, result) {
|
|
410
|
-
if (result == null) {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
for (const incrementalDataRecord of exeContext.subsequentPayloads) {
|
|
414
|
-
if (!isDeferredFragmentRecord(incrementalDataRecord) || !incrementalDataRecord.isCompleted) {
|
|
415
|
-
continue;
|
|
416
|
-
}
|
|
417
|
-
const target = getObjectAtPath(result, incrementalDataRecord.path);
|
|
418
|
-
if (!target) {
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
if (incrementalDataRecord.data != null) {
|
|
422
|
-
Object.assign(target, incrementalDataRecord.data);
|
|
423
|
-
}
|
|
424
|
-
if (incrementalDataRecord.errors.length > 0) {
|
|
425
|
-
exeContext.errors.push(...incrementalDataRecord.errors);
|
|
426
|
-
}
|
|
427
|
-
exeContext.subsequentPayloads.delete(incrementalDataRecord);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
376
|
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord) {
|
|
431
377
|
const schemaFragment = exeContext.schemaFragment;
|
|
432
378
|
const fieldName = fieldGroup[0].name.value;
|
|
@@ -2033,41 +1979,19 @@ function getCompletedIncrementalResults(exeContext) {
|
|
|
2033
1979
|
}
|
|
2034
1980
|
return incrementalResults;
|
|
2035
1981
|
}
|
|
2036
|
-
function waitForCompletedSubsequentPayload(exeContext) {
|
|
2037
|
-
return Promise.race(
|
|
2038
|
-
Array.from(exeContext.subsequentPayloads).map((p) => p.promise)
|
|
2039
|
-
);
|
|
2040
|
-
}
|
|
2041
|
-
function waitForBatchInterval() {
|
|
2042
|
-
return new Promise(
|
|
2043
|
-
(resolve) => setTimeout(resolve, SUBSEQUENT_PAYLOAD_BATCH_INTERVAL_MS, "timeout")
|
|
2044
|
-
);
|
|
2045
|
-
}
|
|
2046
|
-
async function getCompletedIncrementalResultsWithBatching(exeContext) {
|
|
2047
|
-
const incremental = getCompletedIncrementalResults(exeContext);
|
|
2048
|
-
while (incremental.length && exeContext.subsequentPayloads.size > 0) {
|
|
2049
|
-
const result = await Promise.race([
|
|
2050
|
-
waitForCompletedSubsequentPayload(exeContext).then(() => "payload"),
|
|
2051
|
-
waitForBatchInterval()
|
|
2052
|
-
]);
|
|
2053
|
-
if (result === "timeout") {
|
|
2054
|
-
break;
|
|
2055
|
-
}
|
|
2056
|
-
incremental.push(...getCompletedIncrementalResults(exeContext));
|
|
2057
|
-
}
|
|
2058
|
-
return incremental;
|
|
2059
|
-
}
|
|
2060
1982
|
function yieldSubsequentPayloads(exeContext) {
|
|
2061
1983
|
let isDone = false;
|
|
2062
1984
|
async function next() {
|
|
2063
1985
|
if (isDone) {
|
|
2064
1986
|
return { value: void 0, done: true };
|
|
2065
1987
|
}
|
|
2066
|
-
await
|
|
1988
|
+
await Promise.race(
|
|
1989
|
+
Array.from(exeContext.subsequentPayloads).map((p) => p.promise)
|
|
1990
|
+
);
|
|
2067
1991
|
if (isDone) {
|
|
2068
1992
|
return { value: void 0, done: true };
|
|
2069
1993
|
}
|
|
2070
|
-
const incremental =
|
|
1994
|
+
const incremental = getCompletedIncrementalResults(exeContext);
|
|
2071
1995
|
const hasNext = exeContext.subsequentPayloads.size > 0;
|
|
2072
1996
|
if (!incremental.length && hasNext) {
|
|
2073
1997
|
return next();
|
|
@@ -2110,9 +2034,6 @@ function yieldSubsequentPayloads(exeContext) {
|
|
|
2110
2034
|
function isStreamItemsRecord(incrementalDataRecord) {
|
|
2111
2035
|
return incrementalDataRecord.type === "stream";
|
|
2112
2036
|
}
|
|
2113
|
-
function isDeferredFragmentRecord(incrementalDataRecord) {
|
|
2114
|
-
return incrementalDataRecord.type === "defer";
|
|
2115
|
-
}
|
|
2116
2037
|
var DeferredFragmentRecord = class {
|
|
2117
2038
|
constructor(opts) {
|
|
2118
2039
|
this.type = "defer";
|