@graphitation/supermassive 3.17.0 → 3.18.1-canary.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 +2 -2
- package/lib/executeWithSchema.d.ts +1 -1
- package/lib/executeWithSchema.d.ts.map +1 -1
- package/lib/executeWithSchema.js +6 -2
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +6 -2
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +3 -0
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +107 -20
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +107 -20
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/jsutils/getObjectAtPath.d.ts +8 -0
- package/lib/jsutils/getObjectAtPath.d.ts.map +1 -0
- package/lib/jsutils/getObjectAtPath.js +34 -0
- package/lib/jsutils/getObjectAtPath.js.map +7 -0
- package/lib/jsutils/getObjectAtPath.mjs +15 -0
- package/lib/jsutils/getObjectAtPath.mjs.map +7 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ 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";
|
|
12
13
|
import { inspect } from "./jsutils/inspect.mjs";
|
|
13
14
|
import { invariant } from "./jsutils/invariant.mjs";
|
|
14
15
|
import { isIterableObject } from "./jsutils/isIterableObject.mjs";
|
|
@@ -69,7 +70,9 @@ function buildExecutionContext(args) {
|
|
|
69
70
|
typeResolver,
|
|
70
71
|
subscribeFieldResolver,
|
|
71
72
|
fieldExecutionHooks,
|
|
72
|
-
enablePerEventContext
|
|
73
|
+
enablePerEventContext,
|
|
74
|
+
enableEarlyExecution,
|
|
75
|
+
enableDeferredMerge
|
|
73
76
|
} = args;
|
|
74
77
|
assertValidExecutionArguments(document, variableValues);
|
|
75
78
|
let operation;
|
|
@@ -127,7 +130,9 @@ function buildExecutionContext(args) {
|
|
|
127
130
|
errors: [],
|
|
128
131
|
fieldExecutionHooks,
|
|
129
132
|
subsequentPayloads: /* @__PURE__ */ new Set(),
|
|
130
|
-
enablePerEventContext: enablePerEventContext != null ? enablePerEventContext : true
|
|
133
|
+
enablePerEventContext: enablePerEventContext != null ? enablePerEventContext : true,
|
|
134
|
+
enableEarlyExecution: enableEarlyExecution != null ? enableEarlyExecution : false,
|
|
135
|
+
enableDeferredMerge: enableDeferredMerge != null ? enableDeferredMerge : false
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
138
|
function buildPerEventExecutionContext(exeContext, payload) {
|
|
@@ -176,7 +181,8 @@ function executeOperation(exeContext) {
|
|
|
176
181
|
rootValue,
|
|
177
182
|
path,
|
|
178
183
|
groupedFieldSet,
|
|
179
|
-
void 0
|
|
184
|
+
void 0,
|
|
185
|
+
exeContext.enableEarlyExecution ? patches : void 0
|
|
180
186
|
);
|
|
181
187
|
result = buildResponse(exeContext, result);
|
|
182
188
|
break;
|
|
@@ -186,7 +192,8 @@ function executeOperation(exeContext) {
|
|
|
186
192
|
rootTypeName,
|
|
187
193
|
rootValue,
|
|
188
194
|
path,
|
|
189
|
-
groupedFieldSet
|
|
195
|
+
groupedFieldSet,
|
|
196
|
+
exeContext.enableEarlyExecution ? patches : void 0
|
|
190
197
|
);
|
|
191
198
|
result = buildResponse(exeContext, result);
|
|
192
199
|
break;
|
|
@@ -207,16 +214,18 @@ function executeOperation(exeContext) {
|
|
|
207
214
|
`Operation "${operation.operation}" is not a part of GraphQL spec`
|
|
208
215
|
);
|
|
209
216
|
}
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
if (!exeContext.enableEarlyExecution) {
|
|
218
|
+
for (const patch of patches) {
|
|
219
|
+
const { label, groupedFieldSet: patchGroupedFieldSet } = patch;
|
|
220
|
+
executeDeferredFragment(
|
|
221
|
+
exeContext,
|
|
222
|
+
rootTypeName,
|
|
223
|
+
rootValue,
|
|
224
|
+
patchGroupedFieldSet,
|
|
225
|
+
label,
|
|
226
|
+
path
|
|
227
|
+
);
|
|
228
|
+
}
|
|
220
229
|
}
|
|
221
230
|
return result;
|
|
222
231
|
} catch (error) {
|
|
@@ -237,6 +246,9 @@ function buildResponse(exeContext, data) {
|
|
|
237
246
|
}
|
|
238
247
|
const hooks = exeContext.fieldExecutionHooks;
|
|
239
248
|
try {
|
|
249
|
+
if (exeContext.enableDeferredMerge) {
|
|
250
|
+
includeCompletedDeferredFragmentsInResult(exeContext, data);
|
|
251
|
+
}
|
|
240
252
|
const initialResult = exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data };
|
|
241
253
|
if (exeContext.subsequentPayloads.size > 0) {
|
|
242
254
|
return {
|
|
@@ -266,7 +278,17 @@ function buildResponse(exeContext, data) {
|
|
|
266
278
|
return buildResponse(exeContext, null);
|
|
267
279
|
}
|
|
268
280
|
}
|
|
269
|
-
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, groupedFieldSet) {
|
|
281
|
+
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, groupedFieldSet, patches) {
|
|
282
|
+
if (exeContext.enableEarlyExecution) {
|
|
283
|
+
startExecutingPatches(
|
|
284
|
+
exeContext,
|
|
285
|
+
parentTypeName,
|
|
286
|
+
sourceValue,
|
|
287
|
+
path,
|
|
288
|
+
patches,
|
|
289
|
+
void 0
|
|
290
|
+
);
|
|
291
|
+
}
|
|
270
292
|
return promiseReduce(
|
|
271
293
|
groupedFieldSet,
|
|
272
294
|
(results, [responseName, fieldGroup]) => {
|
|
@@ -297,9 +319,19 @@ function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, gr
|
|
|
297
319
|
/* @__PURE__ */ Object.create(null)
|
|
298
320
|
);
|
|
299
321
|
}
|
|
300
|
-
function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFieldSet, incrementalDataRecord) {
|
|
322
|
+
function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFieldSet, incrementalDataRecord, patches) {
|
|
301
323
|
const results = /* @__PURE__ */ Object.create(null);
|
|
302
324
|
let containsPromise = false;
|
|
325
|
+
if (exeContext.enableEarlyExecution) {
|
|
326
|
+
startExecutingPatches(
|
|
327
|
+
exeContext,
|
|
328
|
+
parentTypeName,
|
|
329
|
+
sourceValue,
|
|
330
|
+
path,
|
|
331
|
+
patches,
|
|
332
|
+
incrementalDataRecord
|
|
333
|
+
);
|
|
334
|
+
}
|
|
303
335
|
try {
|
|
304
336
|
for (const [responseName, fieldGroup] of groupedFieldSet) {
|
|
305
337
|
const fieldPath = addPath(path, responseName, parentTypeName);
|
|
@@ -331,6 +363,43 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, groupedFie
|
|
|
331
363
|
}
|
|
332
364
|
return promiseForObject(results);
|
|
333
365
|
}
|
|
366
|
+
function startExecutingPatches(exeContext, parentTypeName, sourceValue, path, patches, incrementalDataRecord) {
|
|
367
|
+
if (!patches) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
for (const { label, groupedFieldSet: patchGroupedFieldSet } of patches) {
|
|
371
|
+
executeDeferredFragment(
|
|
372
|
+
exeContext,
|
|
373
|
+
parentTypeName,
|
|
374
|
+
sourceValue,
|
|
375
|
+
patchGroupedFieldSet,
|
|
376
|
+
label,
|
|
377
|
+
path,
|
|
378
|
+
incrementalDataRecord
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function includeCompletedDeferredFragmentsInResult(exeContext, result) {
|
|
383
|
+
if (result == null) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
for (const incrementalDataRecord of exeContext.subsequentPayloads) {
|
|
387
|
+
if (!isDeferredFragmentRecord(incrementalDataRecord) || !incrementalDataRecord.isCompleted) {
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
const target = getObjectAtPath(result, incrementalDataRecord.path);
|
|
391
|
+
if (!target) {
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (incrementalDataRecord.data != null) {
|
|
395
|
+
Object.assign(target, incrementalDataRecord.data);
|
|
396
|
+
}
|
|
397
|
+
if (incrementalDataRecord.errors.length > 0) {
|
|
398
|
+
exeContext.errors.push(...incrementalDataRecord.errors);
|
|
399
|
+
}
|
|
400
|
+
exeContext.subsequentPayloads.delete(incrementalDataRecord);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
334
403
|
function executeField(exeContext, parentTypeName, source, fieldGroup, path, incrementalDataRecord) {
|
|
335
404
|
const schemaFragment = exeContext.schemaFragment;
|
|
336
405
|
const fieldName = fieldGroup[0].name.value;
|
|
@@ -1308,6 +1377,17 @@ function completeObjectValue(exeContext, returnTypeName, fieldGroup, path, resul
|
|
|
1308
1377
|
}
|
|
1309
1378
|
function collectAndExecuteSubfields(exeContext, returnTypeName, fieldGroup, path, result, incrementalDataRecord) {
|
|
1310
1379
|
const { groupedFieldSet: subGroupedFieldSet, patches: subPatches } = collectSubfields(exeContext, { name: returnTypeName }, fieldGroup);
|
|
1380
|
+
if (exeContext.enableEarlyExecution) {
|
|
1381
|
+
return executeFields(
|
|
1382
|
+
exeContext,
|
|
1383
|
+
returnTypeName,
|
|
1384
|
+
result,
|
|
1385
|
+
path,
|
|
1386
|
+
subGroupedFieldSet,
|
|
1387
|
+
incrementalDataRecord,
|
|
1388
|
+
subPatches
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1311
1391
|
const subFields = executeFields(
|
|
1312
1392
|
exeContext,
|
|
1313
1393
|
returnTypeName,
|
|
@@ -1981,6 +2061,9 @@ function yieldSubsequentPayloads(exeContext) {
|
|
|
1981
2061
|
function isStreamItemsRecord(incrementalDataRecord) {
|
|
1982
2062
|
return incrementalDataRecord.type === "stream";
|
|
1983
2063
|
}
|
|
2064
|
+
function isDeferredFragmentRecord(incrementalDataRecord) {
|
|
2065
|
+
return incrementalDataRecord.type === "defer";
|
|
2066
|
+
}
|
|
1984
2067
|
var DeferredFragmentRecord = class {
|
|
1985
2068
|
constructor(opts) {
|
|
1986
2069
|
this.type = "defer";
|
|
@@ -1996,10 +2079,11 @@ var DeferredFragmentRecord = class {
|
|
|
1996
2079
|
this._resolve = (promiseOrValue) => {
|
|
1997
2080
|
resolve(promiseOrValue);
|
|
1998
2081
|
};
|
|
1999
|
-
}).then((data) =>
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2082
|
+
}).then((data) => this.complete(data));
|
|
2083
|
+
}
|
|
2084
|
+
complete(data) {
|
|
2085
|
+
this.data = data;
|
|
2086
|
+
this.isCompleted = true;
|
|
2003
2087
|
}
|
|
2004
2088
|
addData(data) {
|
|
2005
2089
|
var _a, _b, _c;
|
|
@@ -2008,6 +2092,9 @@ var DeferredFragmentRecord = class {
|
|
|
2008
2092
|
(_b = this._resolve) == null ? void 0 : _b.call(this, parentData.then(() => data));
|
|
2009
2093
|
return;
|
|
2010
2094
|
}
|
|
2095
|
+
if (!isPromise(data)) {
|
|
2096
|
+
this.complete(data);
|
|
2097
|
+
}
|
|
2011
2098
|
(_c = this._resolve) == null ? void 0 : _c.call(this, data);
|
|
2012
2099
|
}
|
|
2013
2100
|
};
|