grafast 1.0.0-rc.4 → 1.0.0-rc.6
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/dist/args.d.ts +1 -1
- package/dist/args.js +7 -7
- package/dist/engine/LayerPlan.d.ts +6 -6
- package/dist/engine/LayerPlan.js +44 -44
- package/dist/engine/OperationPlan.d.ts +28 -31
- package/dist/engine/OperationPlan.js +239 -242
- package/dist/engine/OperationPlanTypes.d.ts +10 -5
- package/dist/engine/OutputPlan.d.ts +8 -8
- package/dist/engine/OutputPlan.js +30 -30
- package/dist/engine/StepTracker.js +36 -36
- package/dist/engine/distributor.d.ts +4 -3
- package/dist/engine/distributor.js +17 -16
- package/dist/engine/executeBucket.d.ts +2 -2
- package/dist/engine/executeBucket.js +101 -101
- package/dist/engine/executeOutputPlan.d.ts +2 -2
- package/dist/engine/executeOutputPlan.js +2 -2
- package/dist/engine/lib/defaultPlanResolver.d.ts +1 -1
- package/dist/engine/lib/defaultPlanResolver.js +2 -2
- package/dist/engine/lib/withGlobalLayerPlan.d.ts +3 -3
- package/dist/engine/lib/withGlobalLayerPlan.js +12 -12
- package/dist/engine/lock.d.ts +1 -1
- package/dist/envelop.js +7 -7
- package/dist/error.d.ts +3 -3
- package/dist/error.js +14 -14
- package/dist/establishOperationPlan.d.ts +3 -3
- package/dist/establishOperationPlan.js +16 -16
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +15 -16
- package/dist/exportAs.js +2 -2
- package/dist/global.d.ts +2 -2
- package/dist/global.js +2 -2
- package/dist/grafastGraphql.d.ts +2 -2
- package/dist/grafastGraphql.js +16 -16
- package/dist/grafastPrint.d.ts +1 -1
- package/dist/grafastPrint.js +31 -31
- package/dist/graphqlCollectFields.d.ts +1 -1
- package/dist/graphqlCollectFields.js +2 -2
- package/dist/graphqlMergeSelectionSets.d.ts +1 -1
- package/dist/graphqlMergeSelectionSets.js +2 -2
- package/dist/index.d.ts +40 -35
- package/dist/index.js +322 -322
- package/dist/input.d.ts +2 -2
- package/dist/input.js +23 -23
- package/dist/interfaces.d.ts +13 -13
- package/dist/makeGrafastSchema.d.ts +2 -2
- package/dist/makeGrafastSchema.js +33 -33
- package/dist/mermaid.d.ts +2 -2
- package/dist/mermaid.js +4 -6
- package/dist/multistep.d.ts +2 -2
- package/dist/multistep.js +13 -13
- package/dist/operationPlan-input.d.ts +3 -3
- package/dist/operationPlan-input.js +13 -13
- package/dist/planJSONInterfaces.d.ts +1 -1
- package/dist/prepare.d.ts +1 -1
- package/dist/prepare.js +75 -75
- package/dist/step.d.ts +6 -6
- package/dist/step.js +29 -29
- package/dist/steps/__cloneStream.d.ts +4 -4
- package/dist/steps/__cloneStream.js +4 -4
- package/dist/steps/__flag.d.ts +4 -4
- package/dist/steps/__flag.js +39 -39
- package/dist/steps/__inputDefault.d.ts +4 -4
- package/dist/steps/__inputDefault.js +3 -3
- package/dist/steps/__inputDynamicScalar.d.ts +3 -3
- package/dist/steps/__inputDynamicScalar.js +8 -8
- package/dist/steps/__inputList.d.ts +3 -3
- package/dist/steps/__inputList.js +12 -12
- package/dist/steps/__inputObject.d.ts +5 -5
- package/dist/steps/__inputObject.js +10 -10
- package/dist/steps/__inputStaticLeaf.d.ts +3 -3
- package/dist/steps/__inputStaticLeaf.js +7 -7
- package/dist/steps/__item.d.ts +5 -5
- package/dist/steps/__item.js +5 -5
- package/dist/steps/__trackedValue.d.ts +6 -6
- package/dist/steps/__trackedValue.js +5 -5
- package/dist/steps/__value.d.ts +3 -3
- package/dist/steps/__value.js +6 -6
- package/dist/steps/_loadCommon.d.ts +3 -3
- package/dist/steps/_loadCommon.js +12 -12
- package/dist/steps/access.d.ts +6 -6
- package/dist/steps/access.js +7 -7
- package/dist/steps/applyInput.d.ts +8 -7
- package/dist/steps/applyInput.js +45 -31
- package/dist/steps/applyTransforms.d.ts +1 -1
- package/dist/steps/applyTransforms.js +24 -24
- package/dist/steps/bakedInput.d.ts +4 -4
- package/dist/steps/bakedInput.js +19 -17
- package/dist/steps/coalesce.d.ts +3 -3
- package/dist/steps/coalesce.js +4 -4
- package/dist/steps/condition.d.ts +4 -4
- package/dist/steps/condition.js +3 -3
- package/dist/steps/connection.d.ts +9 -9
- package/dist/steps/connection.js +41 -41
- package/dist/steps/constant.d.ts +4 -4
- package/dist/steps/constant.js +11 -11
- package/dist/steps/each.d.ts +4 -4
- package/dist/steps/each.js +7 -7
- package/dist/steps/error.d.ts +2 -2
- package/dist/steps/error.js +8 -8
- package/dist/steps/filter.d.ts +4 -4
- package/dist/steps/filter.js +4 -4
- package/dist/steps/first.d.ts +4 -4
- package/dist/steps/first.js +8 -8
- package/dist/steps/get.d.ts +1 -1
- package/dist/steps/get.js +2 -2
- package/dist/steps/graphqlResolver.d.ts +2 -2
- package/dist/steps/graphqlResolver.js +12 -12
- package/dist/steps/groupBy.d.ts +3 -3
- package/dist/steps/groupBy.js +6 -6
- package/dist/steps/index.d.ts +49 -38
- package/dist/steps/index.js +120 -120
- package/dist/steps/lambda.d.ts +5 -5
- package/dist/steps/lambda.js +7 -7
- package/dist/steps/last.d.ts +4 -4
- package/dist/steps/last.js +8 -8
- package/dist/steps/list.d.ts +6 -6
- package/dist/steps/list.js +6 -6
- package/dist/steps/listTransform.d.ts +7 -7
- package/dist/steps/listTransform.js +21 -21
- package/dist/steps/listen.d.ts +4 -4
- package/dist/steps/listen.js +10 -10
- package/dist/steps/loadMany.d.ts +7 -7
- package/dist/steps/loadMany.js +22 -22
- package/dist/steps/loadOne.d.ts +5 -5
- package/dist/steps/loadOne.js +17 -17
- package/dist/steps/loadedRecord.d.ts +8 -8
- package/dist/steps/loadedRecord.js +15 -15
- package/dist/steps/node.d.ts +4 -4
- package/dist/steps/node.js +5 -5
- package/dist/steps/object.d.ts +6 -6
- package/dist/steps/object.js +14 -14
- package/dist/steps/partitionByIndex.d.ts +3 -3
- package/dist/steps/partitionByIndex.js +6 -6
- package/dist/steps/proxy.d.ts +3 -3
- package/dist/steps/proxy.js +7 -7
- package/dist/steps/remapKeys.d.ts +4 -4
- package/dist/steps/remapKeys.js +5 -5
- package/dist/steps/reverse.d.ts +3 -3
- package/dist/steps/reverse.js +2 -2
- package/dist/steps/setter.d.ts +2 -2
- package/dist/steps/setter.js +2 -2
- package/dist/steps/sideEffect.d.ts +5 -5
- package/dist/steps/sideEffect.js +5 -5
- package/dist/stringifyPayload.d.ts +1 -1
- package/dist/subscribe.d.ts +2 -2
- package/dist/subscribe.js +5 -5
- package/dist/unbatchedStepExecute.js +7 -7
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +13 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/dist/args.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExecutionArgs } from "graphql";
|
|
2
|
-
import type { GrafastExecutionArgs, PromiseOrDirect } from "./interfaces.
|
|
2
|
+
import type { GrafastExecutionArgs, PromiseOrDirect } from "./interfaces.ts";
|
|
3
3
|
/** @deprecated Pass `resolvedPreset` and `requestContext` via args directly */
|
|
4
4
|
export declare function hookArgs(rawArgs: ExecutionArgs, resolvedPreset: GraphileConfig.ResolvedPreset, ctx: Partial<Grafast.RequestContext>): PromiseOrDirect<Grafast.ExecutionArgs>;
|
|
5
5
|
export declare function hookArgs(rawArgs: GrafastExecutionArgs): PromiseOrDirect<Grafast.ExecutionArgs>;
|
package/dist/args.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hookArgs = hookArgs;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const constants_ts_1 = require("./constants.js");
|
|
5
|
+
const middleware_ts_1 = require("./middleware.js");
|
|
6
|
+
const utils_ts_1 = require("./utils.js");
|
|
7
7
|
const EMPTY_OBJECT = Object.freeze(Object.create(null));
|
|
8
8
|
const $$writeTest = Symbol("grafastWriteTest");
|
|
9
9
|
/**
|
|
@@ -28,17 +28,17 @@ function hookArgs(rawArgs, legacyResolvedPreset, legacyCtx) {
|
|
|
28
28
|
rawArgs.contextValue = Object.assign(Object.create(null), rawContextValue);
|
|
29
29
|
}
|
|
30
30
|
const middleware = rawMiddleware === undefined && resolvedPreset != null
|
|
31
|
-
? (0,
|
|
31
|
+
? (0, middleware_ts_1.getGrafastMiddleware)(resolvedPreset)
|
|
32
32
|
: (rawMiddleware ?? null);
|
|
33
33
|
if (rawMiddleware === undefined) {
|
|
34
34
|
rawArgs.middleware = middleware;
|
|
35
35
|
}
|
|
36
36
|
const args = rawArgs;
|
|
37
37
|
// Assert that args haven't already been hooked
|
|
38
|
-
if (args[
|
|
38
|
+
if (args[constants_ts_1.$$hooked]) {
|
|
39
39
|
throw new Error("Must not call hookArgs twice!");
|
|
40
40
|
}
|
|
41
|
-
args[
|
|
41
|
+
args[constants_ts_1.$$hooked] = true;
|
|
42
42
|
if (middleware != null) {
|
|
43
43
|
return middleware.run("prepareArgs", { args }, finalizeWithEvent);
|
|
44
44
|
}
|
|
@@ -51,7 +51,7 @@ function finalize(args) {
|
|
|
51
51
|
const contextValue = args.contextValue;
|
|
52
52
|
if (typeof userContext === "function") {
|
|
53
53
|
const result = userContext(args.requestContext ?? EMPTY_OBJECT, args);
|
|
54
|
-
if ((0,
|
|
54
|
+
if ((0, utils_ts_1.isPromiseLike)(result)) {
|
|
55
55
|
// Deliberately shadowed 'result'
|
|
56
56
|
return result.then((result) => {
|
|
57
57
|
Object.assign(contextValue, result);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Bucket } from "../bucket.
|
|
2
|
-
import type { Step } from "../step";
|
|
3
|
-
import type { __ValueStep } from "../steps/index.
|
|
4
|
-
import type { OperationPlan } from "./OperationPlan";
|
|
1
|
+
import type { Bucket } from "../bucket.ts";
|
|
2
|
+
import type { Step } from "../step.ts";
|
|
3
|
+
import type { __ValueStep } from "../steps/index.ts";
|
|
4
|
+
import type { OperationPlan } from "./OperationPlan.ts";
|
|
5
5
|
/** Non-branching, non-deferred */
|
|
6
6
|
export interface LayerPlanReasonRoot {
|
|
7
7
|
type: "root";
|
|
@@ -150,8 +150,6 @@ export type LayerPlanReasonsWithParentStep = HasParent<LayerPlanReason>;
|
|
|
150
150
|
*
|
|
151
151
|
*/
|
|
152
152
|
export declare class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason> {
|
|
153
|
-
readonly operationPlan: OperationPlan;
|
|
154
|
-
readonly reason: TReason;
|
|
155
153
|
id: number;
|
|
156
154
|
distributorDependencies: null | {
|
|
157
155
|
[distributorStepId: number]: number[];
|
|
@@ -176,6 +174,8 @@ export declare class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason
|
|
|
176
174
|
*/
|
|
177
175
|
outOfBoundsLayerPlanIds: Set<number>;
|
|
178
176
|
private sideEffectRootLayerPlan;
|
|
177
|
+
readonly operationPlan: OperationPlan;
|
|
178
|
+
readonly reason: TReason;
|
|
179
179
|
constructor(operationPlan: OperationPlan, reason: TReason);
|
|
180
180
|
toString(): string;
|
|
181
181
|
print(depth?: number): string;
|
package/dist/engine/LayerPlan.js
CHANGED
|
@@ -5,23 +5,23 @@ exports.hasParentLayerPlan = hasParentLayerPlan;
|
|
|
5
5
|
exports.isDeferredLayerPlan = isDeferredLayerPlan;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const assert = tslib_1.__importStar(require("../assert.js"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
8
|
+
const constants_ts_1 = require("../constants.js");
|
|
9
|
+
const dev_ts_1 = require("../dev.js");
|
|
10
|
+
const error_ts_1 = require("../error.js");
|
|
11
|
+
const inspect_ts_1 = require("../inspect.js");
|
|
12
|
+
const utils_ts_1 = require("../utils.js");
|
|
13
|
+
const distributor_ts_1 = require("./distributor.js");
|
|
14
|
+
const executeBucket_ts_1 = require("./executeBucket.js");
|
|
15
15
|
/**
|
|
16
16
|
* If any of these flags exist on a value then it isn't the value we want to
|
|
17
17
|
* include for the combo step.
|
|
18
18
|
*/
|
|
19
|
-
const SKIP_FLAGS =
|
|
19
|
+
const SKIP_FLAGS = constants_ts_1.FLAG_ERROR | constants_ts_1.FLAG_STOPPED | constants_ts_1.FLAG_POLY_SKIPPED | constants_ts_1.FLAG_INHIBITED;
|
|
20
20
|
/**
|
|
21
21
|
* If any of these flags exist on the "$__typename" step, then the value
|
|
22
22
|
* should resolve to null
|
|
23
23
|
*/
|
|
24
|
-
const NO_TYPENAME_FLAGS =
|
|
24
|
+
const NO_TYPENAME_FLAGS = constants_ts_1.FLAG_ERROR | constants_ts_1.FLAG_STOPPED | constants_ts_1.FLAG_POLY_SKIPPED | constants_ts_1.FLAG_INHIBITED | constants_ts_1.FLAG_NULL;
|
|
25
25
|
function hasParentLayerPlan(reason) {
|
|
26
26
|
return reason.type !== "root" && reason.type !== "combined";
|
|
27
27
|
}
|
|
@@ -59,11 +59,6 @@ function isDeferredLayerPlan(layerPlan) {
|
|
|
59
59
|
*/
|
|
60
60
|
class LayerPlan {
|
|
61
61
|
constructor(operationPlan, reason) {
|
|
62
|
-
// This layer plan is dependent on the latest side effect. Note that when
|
|
63
|
-
// we set a `rootStep` later, if the root step is dependent on this step
|
|
64
|
-
// (directly or indirectly) we will clear this property.
|
|
65
|
-
this.operationPlan = operationPlan;
|
|
66
|
-
this.reason = reason;
|
|
67
62
|
/**
|
|
68
63
|
* Every layer plan has a "root step" that shapes the value the layer
|
|
69
64
|
* returns. Note that this step may be dependent on other steps included in
|
|
@@ -133,6 +128,11 @@ class LayerPlan {
|
|
|
133
128
|
this.combinations = [];
|
|
134
129
|
/** @internal */
|
|
135
130
|
this.finalCombinations = [];
|
|
131
|
+
this.operationPlan = operationPlan;
|
|
132
|
+
this.reason = reason;
|
|
133
|
+
// This layer plan is dependent on the latest side effect. Note that when
|
|
134
|
+
// we set a `rootStep` later, if the root step is dependent on this step
|
|
135
|
+
// (directly or indirectly) we will clear this property.
|
|
136
136
|
this.stepsByConstructor = new Map();
|
|
137
137
|
if (reason.type === "root") {
|
|
138
138
|
this.sideEffectRootLayerPlan = null;
|
|
@@ -148,7 +148,7 @@ class LayerPlan {
|
|
|
148
148
|
const firstParentLayerPlan = reason.parentLayerPlans[0];
|
|
149
149
|
this.sideEffectRootLayerPlan =
|
|
150
150
|
firstParentLayerPlan.sideEffectRootLayerPlan;
|
|
151
|
-
if (
|
|
151
|
+
if (dev_ts_1.isDev) {
|
|
152
152
|
for (const plp of reason.parentLayerPlans) {
|
|
153
153
|
assert.strictEqual(plp.sideEffectRootLayerPlan, this.sideEffectRootLayerPlan, `Expected all parentLayerPlans to have the same sideEffectRootLayerPlan`);
|
|
154
154
|
}
|
|
@@ -323,7 +323,7 @@ class LayerPlan {
|
|
|
323
323
|
const hasNoNullsOrErrors = false;
|
|
324
324
|
if (this.rootStep._isUnary) {
|
|
325
325
|
const fieldValue = parentBucket.store.get(itemStepId);
|
|
326
|
-
const forbiddenFlags = fieldValue._entryFlags &
|
|
326
|
+
const forbiddenFlags = fieldValue._entryFlags & constants_ts_1.FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS;
|
|
327
327
|
if (forbiddenFlags) {
|
|
328
328
|
size = 0;
|
|
329
329
|
}
|
|
@@ -334,7 +334,7 @@ class LayerPlan {
|
|
|
334
334
|
const orig = parentBucket.store.get(stepId);
|
|
335
335
|
if (orig.isBatch) {
|
|
336
336
|
// Prepare store with an empty list for each copyPlanId
|
|
337
|
-
const ev = (0,
|
|
337
|
+
const ev = (0, executeBucket_ts_1.batchExecutionValue)([]);
|
|
338
338
|
store.set(stepId, ev);
|
|
339
339
|
batchCopy.push({ orig, ev });
|
|
340
340
|
}
|
|
@@ -345,7 +345,7 @@ class LayerPlan {
|
|
|
345
345
|
const parentBucketSize = parentBucket.size;
|
|
346
346
|
for (let originalIndex = 0; originalIndex < parentBucketSize; originalIndex++) {
|
|
347
347
|
if (parentSideEffectValue === null ||
|
|
348
|
-
!(parentSideEffectValue._flagsAt(originalIndex) &
|
|
348
|
+
!(parentSideEffectValue._flagsAt(originalIndex) & constants_ts_1.FLAG_ERROR)) {
|
|
349
349
|
const newIndex = size++;
|
|
350
350
|
map.set(originalIndex, newIndex);
|
|
351
351
|
polymorphicPathList[newIndex] =
|
|
@@ -379,14 +379,14 @@ class LayerPlan {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
else {
|
|
382
|
-
const ev = (0,
|
|
382
|
+
const ev = (0, executeBucket_ts_1.batchExecutionValue)([]);
|
|
383
383
|
store.set(itemStepId, ev);
|
|
384
384
|
const batchCopy = [];
|
|
385
385
|
for (const stepId of copyStepIds) {
|
|
386
386
|
const orig = parentBucket.store.get(stepId);
|
|
387
387
|
if (orig.isBatch) {
|
|
388
388
|
// Prepare store with an empty list for each copyPlanId
|
|
389
|
-
const ev = (0,
|
|
389
|
+
const ev = (0, executeBucket_ts_1.batchExecutionValue)([]);
|
|
390
390
|
store.set(stepId, ev);
|
|
391
391
|
batchCopy.push({ orig, ev });
|
|
392
392
|
}
|
|
@@ -403,8 +403,8 @@ class LayerPlan {
|
|
|
403
403
|
// we must "multiply up" (down) the store entries.
|
|
404
404
|
for (let originalIndex = 0; originalIndex < parentBucket.size; originalIndex++) {
|
|
405
405
|
if ((parentSideEffectValue === null ||
|
|
406
|
-
!(parentSideEffectValue._flagsAt(originalIndex) &
|
|
407
|
-
!(nullableStepStore._flagsAt(originalIndex) &
|
|
406
|
+
!(parentSideEffectValue._flagsAt(originalIndex) & constants_ts_1.FLAG_ERROR)) &&
|
|
407
|
+
!(nullableStepStore._flagsAt(originalIndex) & constants_ts_1.FLAG_NULL)) {
|
|
408
408
|
const newIndex = size++;
|
|
409
409
|
map.set(originalIndex, newIndex);
|
|
410
410
|
ev._copyResult(newIndex, nullableStepStore, originalIndex);
|
|
@@ -436,7 +436,7 @@ class LayerPlan {
|
|
|
436
436
|
if (this.rootStep._isUnary) {
|
|
437
437
|
throw new Error("listItem layer plan can't have a unary root step!");
|
|
438
438
|
}
|
|
439
|
-
const ev = (0,
|
|
439
|
+
const ev = (0, executeBucket_ts_1.batchExecutionValue)([]);
|
|
440
440
|
store.set(itemStepId, ev);
|
|
441
441
|
const batchCopy = [];
|
|
442
442
|
for (const stepId of copyStepIds) {
|
|
@@ -444,7 +444,7 @@ class LayerPlan {
|
|
|
444
444
|
const orig = parentBucket.store.get(stepId);
|
|
445
445
|
if (orig.isBatch) {
|
|
446
446
|
// Prepare store with an empty list for each copyPlanId
|
|
447
|
-
const ev = (0,
|
|
447
|
+
const ev = (0, executeBucket_ts_1.batchExecutionValue)([]);
|
|
448
448
|
store.set(stepId, ev);
|
|
449
449
|
batchCopy.push({ orig, ev });
|
|
450
450
|
}
|
|
@@ -457,7 +457,7 @@ class LayerPlan {
|
|
|
457
457
|
for (let originalIndex = 0; originalIndex < parentBucket.size; originalIndex++) {
|
|
458
458
|
const list = listStepStore.at(originalIndex);
|
|
459
459
|
if ((parentSideEffectValue === null ||
|
|
460
|
-
!(parentSideEffectValue._flagsAt(originalIndex) &
|
|
460
|
+
!(parentSideEffectValue._flagsAt(originalIndex) & constants_ts_1.FLAG_ERROR)) &&
|
|
461
461
|
Array.isArray(list)) {
|
|
462
462
|
const newIndexes = [];
|
|
463
463
|
map.set(originalIndex, newIndexes);
|
|
@@ -465,15 +465,15 @@ class LayerPlan {
|
|
|
465
465
|
const newIndex = size++;
|
|
466
466
|
newIndexes.push(newIndex);
|
|
467
467
|
let val = list[j];
|
|
468
|
-
let flags =
|
|
468
|
+
let flags = constants_ts_1.NO_FLAGS;
|
|
469
469
|
if (val == null) {
|
|
470
|
-
flags = flags |
|
|
470
|
+
flags = flags | constants_ts_1.FLAG_NULL;
|
|
471
471
|
}
|
|
472
|
-
else if (typeof val === "object" && (0,
|
|
472
|
+
else if (typeof val === "object" && (0, error_ts_1.isFlaggedValue)(val)) {
|
|
473
473
|
flags = val.flags;
|
|
474
474
|
val = val.value;
|
|
475
475
|
if (val == null) {
|
|
476
|
-
flags = flags |
|
|
476
|
+
flags = flags | constants_ts_1.FLAG_NULL;
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
ev._setResult(newIndex, val, flags);
|
|
@@ -515,7 +515,7 @@ class LayerPlan {
|
|
|
515
515
|
throw new Error(`GrafastInternalError<548f0d84-4556-4189-8655-fb16aa3345a6>: new bucket for ${this} wants to copy ${this.operationPlan.dangerouslyGetStep(stepId)}, but bucket for ${parentBucket.layerPlan} doesn't contain that plan`);
|
|
516
516
|
}
|
|
517
517
|
if (orig.isBatch) {
|
|
518
|
-
const ev = (0,
|
|
518
|
+
const ev = (0, executeBucket_ts_1.batchExecutionValue)([]);
|
|
519
519
|
store.set(stepId, ev);
|
|
520
520
|
batchCopy.push({ orig, ev });
|
|
521
521
|
}
|
|
@@ -530,7 +530,7 @@ class LayerPlan {
|
|
|
530
530
|
continue;
|
|
531
531
|
}
|
|
532
532
|
if (parentSideEffectValue !== null &&
|
|
533
|
-
parentSideEffectValue._flagsAt(originalIndex) &
|
|
533
|
+
parentSideEffectValue._flagsAt(originalIndex) & constants_ts_1.FLAG_ERROR) {
|
|
534
534
|
skipIndex?.(originalIndex);
|
|
535
535
|
continue;
|
|
536
536
|
}
|
|
@@ -564,7 +564,7 @@ class LayerPlan {
|
|
|
564
564
|
throw new Error(`GrafastInternalError<548f0d84-4556-4189-8655-fb16aa3345a6>: new bucket for ${this} wants to copy ${this.operationPlan.dangerouslyGetStep(stepId)}, but bucket for ${parentBucket.layerPlan} doesn't contain that plan`);
|
|
565
565
|
}
|
|
566
566
|
if (orig.isBatch) {
|
|
567
|
-
const ev = (0,
|
|
567
|
+
const ev = (0, executeBucket_ts_1.batchExecutionValue)([]);
|
|
568
568
|
store.set(stepId, ev);
|
|
569
569
|
batchCopy.push({ orig, ev });
|
|
570
570
|
}
|
|
@@ -574,7 +574,7 @@ class LayerPlan {
|
|
|
574
574
|
}
|
|
575
575
|
for (let originalIndex = 0; originalIndex < parentBucket.size; originalIndex++) {
|
|
576
576
|
if (parentSideEffectValue !== null &&
|
|
577
|
-
parentSideEffectValue._flagsAt(originalIndex) &
|
|
577
|
+
parentSideEffectValue._flagsAt(originalIndex) & constants_ts_1.FLAG_ERROR) {
|
|
578
578
|
skipIndex?.(originalIndex);
|
|
579
579
|
continue;
|
|
580
580
|
}
|
|
@@ -609,12 +609,12 @@ class LayerPlan {
|
|
|
609
609
|
}
|
|
610
610
|
default: {
|
|
611
611
|
const never = this.reason;
|
|
612
|
-
throw new Error(`GrafastInternalError<8162e6c2-3d66-4d67-ba03-5310a4f9a6d4>: unhandled reason '${(0,
|
|
612
|
+
throw new Error(`GrafastInternalError<8162e6c2-3d66-4d67-ba03-5310a4f9a6d4>: unhandled reason '${(0, inspect_ts_1.inspect)(never)}'`);
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
if (size > 0) {
|
|
616
616
|
if (this.distributorDependencies !== null) {
|
|
617
|
-
if (
|
|
617
|
+
if (dev_ts_1.isDev) {
|
|
618
618
|
if (this.reason.type === "listItem") {
|
|
619
619
|
throw new Error(`distributorDependencies should not be set on ${this}`);
|
|
620
620
|
}
|
|
@@ -625,7 +625,7 @@ class LayerPlan {
|
|
|
625
625
|
const distribEV = parentBucket.store.get(Number(distributorStepId));
|
|
626
626
|
for (const originalIndex of skippedIndicies) {
|
|
627
627
|
const v = distribEV.at(originalIndex);
|
|
628
|
-
if ((0,
|
|
628
|
+
if ((0, distributor_ts_1.isDistributor)(v)) {
|
|
629
629
|
for (const consumerStepId of consumerStepIds) {
|
|
630
630
|
v.releaseIfUnused(consumerStepId);
|
|
631
631
|
}
|
|
@@ -635,7 +635,7 @@ class LayerPlan {
|
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
637
|
// Reference
|
|
638
|
-
const childBucket = (0,
|
|
638
|
+
const childBucket = (0, executeBucket_ts_1.newBucket)(parentBucket, {
|
|
639
639
|
layerPlan: this,
|
|
640
640
|
size,
|
|
641
641
|
store,
|
|
@@ -658,7 +658,7 @@ class LayerPlan {
|
|
|
658
658
|
const distribEV = parentBucket.store.get(Number(distributorStepId));
|
|
659
659
|
for (let originalIndex = 0; originalIndex < parentBucketSize; originalIndex++) {
|
|
660
660
|
const v = distribEV.at(originalIndex);
|
|
661
|
-
if ((0,
|
|
661
|
+
if ((0, distributor_ts_1.isDistributor)(v)) {
|
|
662
662
|
for (const consumerStepId of consumerStepIds) {
|
|
663
663
|
v.releaseIfUnused(consumerStepId);
|
|
664
664
|
}
|
|
@@ -680,7 +680,7 @@ class LayerPlan {
|
|
|
680
680
|
const polymorphicPathList = [];
|
|
681
681
|
const iterators = [];
|
|
682
682
|
const mapByParentLayerPlanId = Object.create(null);
|
|
683
|
-
let flagUnion =
|
|
683
|
+
let flagUnion = constants_ts_1.NO_FLAGS;
|
|
684
684
|
let totalSize = 0;
|
|
685
685
|
const batchStepIdsToCopy = new Set();
|
|
686
686
|
for (const plp of this.reason.parentLayerPlans) {
|
|
@@ -717,7 +717,7 @@ class LayerPlan {
|
|
|
717
717
|
if (totalSize === 0)
|
|
718
718
|
return null;
|
|
719
719
|
for (const stepId of batchStepIdsToCopy) {
|
|
720
|
-
const newEv = (0,
|
|
720
|
+
const newEv = (0, executeBucket_ts_1.batchExecutionValue)((0, utils_ts_1.arrayOfLength)(totalSize, null), (0, utils_ts_1.arrayOfLength)(totalSize, constants_ts_1.FLAG_NULL | constants_ts_1.FLAG_STOPPED));
|
|
721
721
|
store.set(stepId, newEv);
|
|
722
722
|
let offset = 0;
|
|
723
723
|
for (const plp of this.reason.parentLayerPlans) {
|
|
@@ -744,7 +744,7 @@ class LayerPlan {
|
|
|
744
744
|
//
|
|
745
745
|
for (const { targetStepId, sourceStepsByLayerPlanId } of this
|
|
746
746
|
.finalCombinations) {
|
|
747
|
-
const ev = (0,
|
|
747
|
+
const ev = (0, executeBucket_ts_1.batchExecutionValue)((0, utils_ts_1.arrayOfLength)(totalSize, null), (0, utils_ts_1.arrayOfLength)(totalSize, constants_ts_1.FLAG_NULL | constants_ts_1.FLAG_STOPPED));
|
|
748
748
|
store.set(targetStepId, ev);
|
|
749
749
|
let offset = 0;
|
|
750
750
|
for (const plp of this.reason.parentLayerPlans) {
|
|
@@ -776,7 +776,7 @@ class LayerPlan {
|
|
|
776
776
|
//
|
|
777
777
|
////////////////////////////////////////////////////////////////////////////
|
|
778
778
|
// Reference
|
|
779
|
-
const childBucket = (0,
|
|
779
|
+
const childBucket = (0, executeBucket_ts_1.newBucket)({ metaByMetaKey: undefined /* use defaults */, sharedState }, {
|
|
780
780
|
layerPlan: this,
|
|
781
781
|
size: totalSize,
|
|
782
782
|
store,
|
|
@@ -826,8 +826,8 @@ class LayerPlan {
|
|
|
826
826
|
// unimportant because probably the order of all subsets will be the
|
|
827
827
|
// same, so we don't need to do an order-independent comparison (which
|
|
828
828
|
// would be more expensiv)
|
|
829
|
-
(0,
|
|
830
|
-
(0,
|
|
829
|
+
(0, utils_ts_1.arraysMatch)(c.reason.typeNames, typeNames) &&
|
|
830
|
+
(0, utils_ts_1.setsMatch)(c.reason.polymorphicPaths, polymorphicPaths));
|
|
831
831
|
if (existing) {
|
|
832
832
|
return existing;
|
|
833
833
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { FragmentDefinitionNode, GraphQLField, GraphQLObjectType, GraphQLOutputType, GraphQLSchema, GraphQLUnionType, OperationDefinitionNode } from "graphql";
|
|
2
|
-
import { $$timeout, $$ts } from "../constants.
|
|
3
|
-
import type { Constraint } from "../constraints.
|
|
4
|
-
import type { ErrorBehavior, GrafastPlanJSON } from "../index.
|
|
5
|
-
import { Step } from "../index.
|
|
6
|
-
import type { FieldPlanResolver, LocationDetails, TrackedArguments } from "../interfaces.
|
|
7
|
-
import type { ApplyAfterModeArg } from "../operationPlan-input.
|
|
8
|
-
import type { GrafastOperationOptions } from "../prepare.
|
|
9
|
-
import type { LayerPlanReasonSubroutine } from "./LayerPlan.
|
|
10
|
-
import { LayerPlan } from "./LayerPlan.
|
|
11
|
-
import type { ProcessGroupedFieldSetDetails, StreamDetails } from "./OperationPlanTypes.
|
|
12
|
-
import { OutputPlan } from "./OutputPlan.
|
|
2
|
+
import { $$timeout, $$ts } from "../constants.ts";
|
|
3
|
+
import type { Constraint } from "../constraints.ts";
|
|
4
|
+
import type { ErrorBehavior, GrafastPlanJSON } from "../index.ts";
|
|
5
|
+
import { Step } from "../index.ts";
|
|
6
|
+
import type { FieldPlanResolver, LocationDetails, TrackedArguments } from "../interfaces.ts";
|
|
7
|
+
import type { ApplyAfterModeArg } from "../operationPlan-input.ts";
|
|
8
|
+
import type { GrafastOperationOptions } from "../prepare.ts";
|
|
9
|
+
import type { LayerPlanReasonSubroutine } from "./LayerPlan.ts";
|
|
10
|
+
import { LayerPlan } from "./LayerPlan.ts";
|
|
11
|
+
import type { ProcessGroupedFieldSetDetails, StreamDetails } from "./OperationPlanTypes.ts";
|
|
12
|
+
import { OutputPlan } from "./OutputPlan.ts";
|
|
13
13
|
export declare const POLYMORPHIC_ROOT_PATH: null;
|
|
14
14
|
export declare const POLYMORPHIC_ROOT_PATHS: ReadonlySet<string> | null;
|
|
15
15
|
/** Beware: the list of phases may change over time... @experimental */
|
|
@@ -18,19 +18,6 @@ export interface MetaByMetaKey {
|
|
|
18
18
|
[metaKey: string | number | symbol]: Record<string, any>;
|
|
19
19
|
}
|
|
20
20
|
export declare class OperationPlan {
|
|
21
|
-
readonly schema: GraphQLSchema;
|
|
22
|
-
readonly operation: OperationDefinitionNode;
|
|
23
|
-
readonly fragments: {
|
|
24
|
-
[fragmentName: string]: FragmentDefinitionNode;
|
|
25
|
-
};
|
|
26
|
-
readonly variableValues: {
|
|
27
|
-
[key: string]: any;
|
|
28
|
-
};
|
|
29
|
-
readonly context: {
|
|
30
|
-
[key: string]: any;
|
|
31
|
-
};
|
|
32
|
-
readonly rootValue: any;
|
|
33
|
-
readonly errorBehavior: ErrorBehavior;
|
|
34
21
|
readonly [$$timeout]: undefined;
|
|
35
22
|
readonly [$$ts]: undefined;
|
|
36
23
|
readonly queryType: GraphQLObjectType;
|
|
@@ -67,6 +54,19 @@ export declare class OperationPlan {
|
|
|
67
54
|
private optimizeMeta;
|
|
68
55
|
private scalarPlanInfo;
|
|
69
56
|
private frozenPlanningPaths;
|
|
57
|
+
readonly schema: GraphQLSchema;
|
|
58
|
+
readonly operation: OperationDefinitionNode;
|
|
59
|
+
readonly fragments: {
|
|
60
|
+
[fragmentName: string]: FragmentDefinitionNode;
|
|
61
|
+
};
|
|
62
|
+
readonly variableValues: {
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
};
|
|
65
|
+
readonly context: {
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
};
|
|
68
|
+
readonly rootValue: any;
|
|
69
|
+
readonly errorBehavior: ErrorBehavior;
|
|
70
70
|
private readonly planningTimeout;
|
|
71
71
|
private readonly maxPlanningDepth;
|
|
72
72
|
constructor(schema: GraphQLSchema, operation: OperationDefinitionNode, fragments: {
|
|
@@ -108,12 +108,9 @@ export declare class OperationPlan {
|
|
|
108
108
|
}>;
|
|
109
109
|
/**
|
|
110
110
|
*
|
|
111
|
-
* @param
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* @param objectType - The object type that this selection set is being evaluated for (note polymorphic selection should already have been handled by this point)
|
|
115
|
-
* @param selections - The GraphQL selections (fields, fragment spreads, inline fragments) to evaluate
|
|
116
|
-
* @param isMutation - If true this selection set should be executed serially rather than in parallel (each field gets its own LayerPlan)
|
|
111
|
+
* @param details - planning details for this selection set. Includes the
|
|
112
|
+
* output plan, path, parent step, position type, selections, and an
|
|
113
|
+
* `isMutation` flag to enforce serial execution.
|
|
117
114
|
*/
|
|
118
115
|
private planSelectionSet;
|
|
119
116
|
private planningQueue;
|
|
@@ -143,7 +140,7 @@ export declare class OperationPlan {
|
|
|
143
140
|
haltTree: boolean;
|
|
144
141
|
latestSideEffectStep: Step<any> | null;
|
|
145
142
|
} | {
|
|
146
|
-
step: import("../index.
|
|
143
|
+
step: import("../index.ts").ErrorStep<any>;
|
|
147
144
|
haltTree: boolean;
|
|
148
145
|
latestSideEffectStep: Step<any> | null;
|
|
149
146
|
};
|