grafast 0.1.1-beta.21 → 0.1.1-beta.22
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/README.md +0 -4
- package/dist/args.js +3 -3
- package/dist/constants.d.ts +79 -0
- package/dist/constants.js +79 -0
- package/dist/engine/LayerPlan.d.ts +71 -8
- package/dist/engine/LayerPlan.js +375 -265
- package/dist/engine/OperationPlan.d.ts +77 -14
- package/dist/engine/OperationPlan.js +1508 -382
- package/dist/engine/OperationPlanTypes.d.ts +66 -0
- package/dist/engine/OperationPlanTypes.js +3 -0
- package/dist/engine/OutputPlan.d.ts +6 -0
- package/dist/engine/OutputPlan.js +138 -82
- package/dist/engine/StepTracker.js +76 -17
- package/dist/engine/executeBucket.js +327 -166
- package/dist/engine/lib/defaultPlanResolver.d.ts +1 -4
- package/dist/engine/lib/defaultPlanResolver.js +1 -5
- package/dist/engine/lib/withGlobalLayerPlan.d.ts +3 -1
- package/dist/engine/lib/withGlobalLayerPlan.js +19 -1
- package/dist/envelop.js +14 -3
- package/dist/error.d.ts +1 -1
- package/dist/error.js +9 -9
- package/dist/establishOperationPlan.d.ts +2 -1
- package/dist/establishOperationPlan.js +10 -10
- package/dist/execute.js +7 -5
- package/dist/global.d.ts +10 -0
- package/dist/global.js +25 -0
- package/dist/grafastGraphql.js +4 -3
- package/dist/grafastPrint.js +36 -4
- package/dist/index.d.ts +76 -8
- package/dist/index.js +37 -33
- package/dist/input.js +20 -1
- package/dist/inspect.js +1 -0
- package/dist/interfaces.d.ts +80 -122
- package/dist/interfaces.js +0 -77
- package/dist/makeGrafastSchema.d.ts +118 -35
- package/dist/makeGrafastSchema.js +197 -29
- package/dist/mermaid.js +198 -97
- package/dist/operationPlan-input.d.ts +1 -1
- package/dist/operationPlan-input.js +15 -5
- package/dist/planJSONInterfaces.d.ts +24 -5
- package/dist/prepare.d.ts +16 -9
- package/dist/prepare.js +54 -51
- package/dist/step.d.ts +45 -9
- package/dist/step.js +139 -22
- package/dist/steps/__flag.d.ts +3 -2
- package/dist/steps/__flag.js +31 -29
- package/dist/steps/__inputObject.d.ts +1 -1
- package/dist/steps/__inputStaticLeaf.d.ts +3 -2
- package/dist/steps/__inputStaticLeaf.js +13 -7
- package/dist/steps/__item.d.ts +1 -1
- package/dist/steps/__item.js +3 -3
- package/dist/steps/__trackedValue.d.ts +6 -3
- package/dist/steps/__trackedValue.js +25 -9
- package/dist/steps/__value.d.ts +2 -1
- package/dist/steps/__value.js +5 -0
- package/dist/steps/access.d.ts +17 -1
- package/dist/steps/access.js +14 -1
- package/dist/steps/applyInput.d.ts +1 -1
- package/dist/steps/applyInput.js +7 -6
- package/dist/steps/applyTransforms.js +9 -7
- package/dist/steps/bakedInput.js +2 -2
- package/dist/steps/coalesce.d.ts +15 -0
- package/dist/steps/coalesce.js +36 -0
- package/dist/steps/constant.js +16 -14
- package/dist/steps/each.d.ts +2 -2
- package/dist/steps/first.d.ts +2 -0
- package/dist/steps/first.js +5 -1
- package/dist/steps/graphqlResolver.d.ts +2 -2
- package/dist/steps/graphqlResolver.js +63 -161
- package/dist/steps/index.d.ts +3 -15
- package/dist/steps/index.js +6 -41
- package/dist/steps/lambda.js +1 -1
- package/dist/steps/last.d.ts +2 -0
- package/dist/steps/last.js +4 -0
- package/dist/steps/listTransform.d.ts +2 -2
- package/dist/steps/listTransform.js +11 -13
- package/dist/steps/load.d.ts +28 -22
- package/dist/steps/load.js +47 -1
- package/dist/steps/node.d.ts +10 -7
- package/dist/steps/node.js +5 -19
- package/dist/steps/object.js +6 -1
- package/dist/steps/proxy.d.ts +0 -6
- package/dist/steps/proxy.js +3 -3
- package/dist/steps/remapKeys.d.ts +1 -1
- package/dist/steps/remapKeys.js +0 -1
- package/dist/utils.d.ts +27 -5
- package/dist/utils.js +235 -15
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
- package/dist/polymorphic.d.ts +0 -14
- package/dist/polymorphic.js +0 -72
- package/dist/steps/polymorphicBranch.d.ts +0 -27
- package/dist/steps/polymorphicBranch.js +0 -62
|
@@ -39,7 +39,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
39
39
|
this.isSyncAndSafe = true;
|
|
40
40
|
this._isImmutable = isImmutable;
|
|
41
41
|
this.addDependency(valuePlan);
|
|
42
|
-
this.
|
|
42
|
+
this._initialValue = value;
|
|
43
43
|
this.constraints = constraints;
|
|
44
44
|
this.path = path;
|
|
45
45
|
this.nullableGraphQLType =
|
|
@@ -97,7 +97,15 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
97
97
|
* Get the named property of an object.
|
|
98
98
|
*/
|
|
99
99
|
get(attrName) {
|
|
100
|
-
|
|
100
|
+
if (this._isImmutable) {
|
|
101
|
+
return this.operationPlan.cacheImmutableStep(`__TrackedValue${this.id}.get`, attrName, () => this._get(attrName));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return this._get(attrName);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_get(attrName) {
|
|
108
|
+
const { _initialValue: value, path, constraints } = this;
|
|
101
109
|
const newValue = value?.[attrName];
|
|
102
110
|
const newValuePlan = this.getValuePlan().get(attrName);
|
|
103
111
|
const newPath = [...path, attrName];
|
|
@@ -145,7 +153,15 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
145
153
|
* Get the entry at the given index in an array.
|
|
146
154
|
*/
|
|
147
155
|
at(index) {
|
|
148
|
-
|
|
156
|
+
if (this._isImmutable) {
|
|
157
|
+
return this.operationPlan.cacheImmutableStep(`__TrackedValue${this.id}.at`, index, () => this._at(index));
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
return this._at(index);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
_at(index) {
|
|
164
|
+
const { _initialValue: value, path, constraints } = this;
|
|
149
165
|
const newValue = value?.[index];
|
|
150
166
|
const newValuePlan = this.getValuePlan().at(index);
|
|
151
167
|
const newPath = [...path, index];
|
|
@@ -176,7 +192,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
176
192
|
* @internal
|
|
177
193
|
*/
|
|
178
194
|
eval() {
|
|
179
|
-
const { path, value } = this;
|
|
195
|
+
const { path, _initialValue: value } = this;
|
|
180
196
|
this.constraints.push({
|
|
181
197
|
type: "value",
|
|
182
198
|
path,
|
|
@@ -196,7 +212,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
196
212
|
* @internal
|
|
197
213
|
*/
|
|
198
214
|
evalIs(expectedValue) {
|
|
199
|
-
const { value, path } = this;
|
|
215
|
+
const { _initialValue: value, path } = this;
|
|
200
216
|
const pass = value === expectedValue;
|
|
201
217
|
this.constraints.push({
|
|
202
218
|
type: "equal",
|
|
@@ -208,7 +224,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
208
224
|
}
|
|
209
225
|
/** @internal */
|
|
210
226
|
evalIsEmpty() {
|
|
211
|
-
const { value, path } = this;
|
|
227
|
+
const { _initialValue: value, path } = this;
|
|
212
228
|
const isEmpty = typeof value === "object" &&
|
|
213
229
|
value !== null &&
|
|
214
230
|
Object.keys(value).length === 0;
|
|
@@ -229,7 +245,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
229
245
|
* @internal
|
|
230
246
|
*/
|
|
231
247
|
evalHas(key) {
|
|
232
|
-
const { value, path } = this;
|
|
248
|
+
const { _initialValue: value, path } = this;
|
|
233
249
|
const newPath = [...path, key];
|
|
234
250
|
// NOTE: `key in value` would be more performant here, but we cannot trust
|
|
235
251
|
// users not to pass `{foo: undefined}` so we must do the more expensive
|
|
@@ -255,7 +271,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
255
271
|
* @internal
|
|
256
272
|
*/
|
|
257
273
|
evalKeys() {
|
|
258
|
-
const { value, path } = this;
|
|
274
|
+
const { _initialValue: value, path } = this;
|
|
259
275
|
if (!(0, graphql_1.isInputObjectType)(this.nullableGraphQLType)) {
|
|
260
276
|
throw new Error("evalKeys must only be called for object types");
|
|
261
277
|
}
|
|
@@ -297,7 +313,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
|
297
313
|
* @internal
|
|
298
314
|
*/
|
|
299
315
|
evalLength() {
|
|
300
|
-
const { value, path } = this;
|
|
316
|
+
const { _initialValue: value, path } = this;
|
|
301
317
|
const length = Array.isArray(value) ? value.length : null;
|
|
302
318
|
this.constraints.push({
|
|
303
319
|
type: "length",
|
package/dist/steps/__value.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GrafastResultsList } from "../
|
|
1
|
+
import type { GrafastResultsList, JSONValue } from "../interfaces.js";
|
|
2
2
|
import { $$noExec, Step } from "../step.js";
|
|
3
3
|
import type { AccessStep } from "./access.js";
|
|
4
4
|
/**
|
|
@@ -14,6 +14,7 @@ export declare class __ValueStep<TData> extends Step<TData> {
|
|
|
14
14
|
isSyncAndSafe: boolean;
|
|
15
15
|
[$$noExec]: boolean;
|
|
16
16
|
constructor(isImmutable: boolean);
|
|
17
|
+
planJSONExtra(): undefined | Record<string, JSONValue>;
|
|
17
18
|
toStringMeta(): string | null;
|
|
18
19
|
execute(): GrafastResultsList<TData>;
|
|
19
20
|
get<TAttr extends keyof TData>(attrName: TAttr): AccessStep<TData[TAttr]>;
|
package/dist/steps/__value.js
CHANGED
|
@@ -21,6 +21,11 @@ class __ValueStep extends step_js_1.Step {
|
|
|
21
21
|
this[_a] = true;
|
|
22
22
|
this._isImmutable = isImmutable;
|
|
23
23
|
}
|
|
24
|
+
planJSONExtra() {
|
|
25
|
+
if (this.layerPlan.reason.type === "combined") {
|
|
26
|
+
return { combined: true };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
24
29
|
toStringMeta() {
|
|
25
30
|
switch (this) {
|
|
26
31
|
case this.operationPlan.rootValueStep:
|
package/dist/steps/access.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare class AccessStep<TData> extends UnbatchedStep<TData> {
|
|
|
30
30
|
* Get the entry at the given index in an array.
|
|
31
31
|
*/
|
|
32
32
|
at<TIndex extends keyof TData>(index: TIndex): AccessStep<TData[TIndex]>;
|
|
33
|
-
optimize():
|
|
33
|
+
optimize(): Step<TData>;
|
|
34
34
|
finalize(): void;
|
|
35
35
|
unbatchedExecute(_extra: UnbatchedExecutionExtra, ..._values: any[]): any;
|
|
36
36
|
deduplicate(peers: AccessStep<unknown>[]): AccessStep<TData>[];
|
|
@@ -40,4 +40,20 @@ export declare class AccessStep<TData> extends UnbatchedStep<TData> {
|
|
|
40
40
|
* falling back to `fallback` if it were null-ish.
|
|
41
41
|
*/
|
|
42
42
|
export declare function access<TData>(parentPlan: Step<unknown>, rawPath?: (string | number | symbol)[] | string | number | symbol, fallback?: any): AccessStep<TData>;
|
|
43
|
+
type StepGetReturn<TStep, TAttr extends string> = TStep extends {
|
|
44
|
+
get: (attr: TAttr) => infer U;
|
|
45
|
+
} ? U : TStep extends {
|
|
46
|
+
get: (attr: string) => infer U;
|
|
47
|
+
} ? U : never;
|
|
48
|
+
type StepGetKeys<TStep extends Step> = TStep extends {
|
|
49
|
+
get(attr: infer U): any;
|
|
50
|
+
} ? U : TStep extends Step<infer UData> ? UData extends Record<string, any> ? keyof UData : string : never;
|
|
51
|
+
type StepAccessKey<TStep extends Step, TAttr extends StepGetKeys<TStep> & string> = TStep extends {
|
|
52
|
+
get(attr: any): any;
|
|
53
|
+
} ? StepGetReturn<TStep, TAttr> : TStep extends Step<infer UData> ? UData extends Record<string, any> ? Step<UData[TAttr]> : Step<any> : never;
|
|
54
|
+
/**
|
|
55
|
+
* Call `$step.get(attr)` if possible, falling back to `access($step, attr)`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function get<TStep extends Step, TAttr extends StepGetKeys<TStep> & string>($step: TStep, attr: TAttr): StepAccessKey<TStep, TAttr>;
|
|
58
|
+
export {};
|
|
43
59
|
//# sourceMappingURL=access.d.ts.map
|
package/dist/steps/access.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AccessStep = exports.expressionSymbol = void 0;
|
|
4
4
|
exports.access = access;
|
|
5
|
+
exports.get = get;
|
|
5
6
|
const tslib_1 = require("tslib");
|
|
6
7
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
8
|
const tamedevil_1 = tslib_1.__importDefault(require("tamedevil"));
|
|
@@ -126,7 +127,7 @@ class AccessStep extends step_js_1.UnbatchedStep {
|
|
|
126
127
|
(this.fallback === "undefined" ? "U" : "D") +
|
|
127
128
|
(this.hasSymbols ? "§" : ".") +
|
|
128
129
|
(0, utils_js_1.digestKeys)(this.path);
|
|
129
|
-
this.
|
|
130
|
+
this.addStrongDependency(parentPlan);
|
|
130
131
|
}
|
|
131
132
|
toStringMeta() {
|
|
132
133
|
return `${chalk_1.default.bold.yellow(String(this.getDepOptions(0).step.id))}.${this.path.map((p) => String(p)).join(".")}`;
|
|
@@ -155,6 +156,10 @@ class AccessStep extends step_js_1.UnbatchedStep {
|
|
|
155
156
|
// An access of an access can become a single access
|
|
156
157
|
optimize() {
|
|
157
158
|
const $dep = this.getDep(0);
|
|
159
|
+
if (this.fallback === undefined && this.path.length === 0) {
|
|
160
|
+
// I don't do anything
|
|
161
|
+
return $dep;
|
|
162
|
+
}
|
|
158
163
|
if ($dep instanceof AccessStep && $dep.fallback === undefined) {
|
|
159
164
|
return access($dep.getDep(0), [...$dep.path, ...this.path], this.fallback);
|
|
160
165
|
}
|
|
@@ -213,4 +218,12 @@ function access(parentPlan, rawPath, fallback) {
|
|
|
213
218
|
}
|
|
214
219
|
return new AccessStep(parentPlan, path, fallback);
|
|
215
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Call `$step.get(attr)` if possible, falling back to `access($step, attr)`.
|
|
223
|
+
*/
|
|
224
|
+
function get($step, attr) {
|
|
225
|
+
return "get" in $step && typeof $step.get === "function"
|
|
226
|
+
? $step.get(attr)
|
|
227
|
+
: access($step, attr);
|
|
228
|
+
}
|
|
216
229
|
//# sourceMappingURL=access.js.map
|
|
@@ -2,7 +2,7 @@ import type { GraphQLInputType, GraphQLSchema } from "graphql";
|
|
|
2
2
|
import type { AnyInputStep, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
3
3
|
import type { Step } from "../step.js";
|
|
4
4
|
import { UnbatchedStep } from "../step.js";
|
|
5
|
-
import { ConstantStep } from "./
|
|
5
|
+
import { ConstantStep } from "./constant.js";
|
|
6
6
|
export declare class ApplyInputStep<TParent extends object = any, TTarget extends object = TParent> extends UnbatchedStep<(arg: TParent) => void> {
|
|
7
7
|
private inputType;
|
|
8
8
|
private getTargetFromParent;
|
package/dist/steps/applyInput.js
CHANGED
|
@@ -7,8 +7,9 @@ exports.isModifier = isModifier;
|
|
|
7
7
|
exports.assertModifier = assertModifier;
|
|
8
8
|
exports.isApplyableStep = isApplyableStep;
|
|
9
9
|
const graphql_1 = require("graphql");
|
|
10
|
+
const global_js_1 = require("../global.js");
|
|
10
11
|
const step_js_1 = require("../step.js");
|
|
11
|
-
const
|
|
12
|
+
const constant_js_1 = require("./constant.js");
|
|
12
13
|
let currentModifiers = [];
|
|
13
14
|
let applyingModifiers = false;
|
|
14
15
|
let inputArgsApplyDepth = 0;
|
|
@@ -35,11 +36,11 @@ class ApplyInputStep extends step_js_1.UnbatchedStep {
|
|
|
35
36
|
}
|
|
36
37
|
optimize() {
|
|
37
38
|
const $value = this.getDep(this.valueDepId);
|
|
38
|
-
if ($value instanceof
|
|
39
|
+
if ($value instanceof constant_js_1.ConstantStep) {
|
|
39
40
|
// Replace myself with a constant!
|
|
40
41
|
const { operationPlan: { schema }, inputType, getTargetFromParent, } = this;
|
|
41
42
|
const { data } = $value;
|
|
42
|
-
return (0,
|
|
43
|
+
return (0, constant_js_1.constant)(function applyInputConstant(parent) {
|
|
43
44
|
inputArgsApply(schema, inputType, parent, data, getTargetFromParent);
|
|
44
45
|
}, false);
|
|
45
46
|
}
|
|
@@ -79,13 +80,13 @@ function inputArgsApply(schema, inputType, parent, inputValue, getTargetFromPare
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
function applyInput(inputType, $value, getTargetFromParent) {
|
|
82
|
-
const opPlan = (0,
|
|
83
|
+
const opPlan = (0, global_js_1.operationPlan)();
|
|
83
84
|
const { schema } = opPlan;
|
|
84
85
|
return opPlan.withRootLayerPlan(() => {
|
|
85
|
-
if ($value instanceof
|
|
86
|
+
if ($value instanceof constant_js_1.ConstantStep) {
|
|
86
87
|
// Replace us with a constant
|
|
87
88
|
const { data } = $value;
|
|
88
|
-
return (0,
|
|
89
|
+
return (0, constant_js_1.constant)(function applyInputConstant(parent) {
|
|
89
90
|
inputArgsApply(schema, inputType, parent, data, getTargetFromParent);
|
|
90
91
|
}, false);
|
|
91
92
|
}
|
|
@@ -4,12 +4,12 @@ exports.ApplyTransformsStep = void 0;
|
|
|
4
4
|
exports.applyTransforms = applyTransforms;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const assert = tslib_1.__importStar(require("../assert.js"));
|
|
7
|
+
const constants_js_1 = require("../constants.js");
|
|
7
8
|
const dev_js_1 = require("../dev.js");
|
|
8
9
|
const executeBucket_js_1 = require("../engine/executeBucket.js");
|
|
9
10
|
const LayerPlan_js_1 = require("../engine/LayerPlan.js");
|
|
10
11
|
const withGlobalLayerPlan_js_1 = require("../engine/lib/withGlobalLayerPlan.js");
|
|
11
12
|
const error_js_1 = require("../error.js");
|
|
12
|
-
const interfaces_js_1 = require("../interfaces.js");
|
|
13
13
|
const step_js_1 = require("../step.js");
|
|
14
14
|
const __item_js_1 = require("./__item.js");
|
|
15
15
|
const connection_js_1 = require("./connection.js");
|
|
@@ -26,13 +26,14 @@ class ApplyTransformsStep extends step_js_1.Step {
|
|
|
26
26
|
// OPTIMIZE: if all the steps in the inner bucket are synchronous then theoretically we can be synchronous too
|
|
27
27
|
this.isSyncAndSafe = false;
|
|
28
28
|
const listPlan = (0, connection_js_1.itemsOrStep)($step);
|
|
29
|
-
this.
|
|
29
|
+
this.addDataDependency(listPlan);
|
|
30
30
|
// Plan this subroutine
|
|
31
|
-
this.subroutineLayer = new LayerPlan_js_1.LayerPlan(this.operationPlan,
|
|
31
|
+
this.subroutineLayer = new LayerPlan_js_1.LayerPlan(this.operationPlan, {
|
|
32
32
|
type: "subroutine",
|
|
33
|
+
parentLayerPlan: this.layerPlan,
|
|
33
34
|
parentStep: this,
|
|
34
35
|
});
|
|
35
|
-
const itemPlan = (0, withGlobalLayerPlan_js_1.withGlobalLayerPlan)(this.subroutineLayer, listPlan.polymorphicPaths, () => {
|
|
36
|
+
const itemPlan = (0, withGlobalLayerPlan_js_1.withGlobalLayerPlan)(this.subroutineLayer, listPlan.polymorphicPaths, null, () => {
|
|
36
37
|
// This does NOT use `itemPlanFor` because __ListTransformPlans are special.
|
|
37
38
|
const $__listItem = new __item_js_1.__ItemStep(listPlan);
|
|
38
39
|
$__listItem.transformStepId = this.id;
|
|
@@ -117,14 +118,15 @@ class ApplyTransformsStep extends step_js_1.Step {
|
|
|
117
118
|
}
|
|
118
119
|
});
|
|
119
120
|
if (size > 0) {
|
|
120
|
-
const childBucket = (0, executeBucket_js_1.newBucket)({
|
|
121
|
+
const childBucket = (0, executeBucket_js_1.newBucket)(bucket, {
|
|
121
122
|
layerPlan: childLayerPlan,
|
|
122
123
|
size,
|
|
123
124
|
store,
|
|
124
125
|
flagUnion: bucket.flagUnion,
|
|
125
126
|
polymorphicPathList,
|
|
127
|
+
polymorphicType: null,
|
|
126
128
|
iterators,
|
|
127
|
-
}
|
|
129
|
+
});
|
|
128
130
|
await (0, executeBucket_js_1.executeBucket)(childBucket, extra._requestContext);
|
|
129
131
|
}
|
|
130
132
|
const depResults = store.get(rootStep.id);
|
|
@@ -140,7 +142,7 @@ class ApplyTransformsStep extends step_js_1.Step {
|
|
|
140
142
|
}
|
|
141
143
|
const values = indexes.map((idx) => {
|
|
142
144
|
const val = depResults.at(idx);
|
|
143
|
-
if (depResults._flagsAt(idx) &
|
|
145
|
+
if (depResults._flagsAt(idx) & constants_js_1.FLAG_ERROR) {
|
|
144
146
|
return (0, error_js_1.flagError)(val);
|
|
145
147
|
}
|
|
146
148
|
return val;
|
package/dist/steps/bakedInput.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.BakedInputStep = void 0;
|
|
|
4
4
|
exports.bakedInput = bakedInput;
|
|
5
5
|
exports.bakedInputRuntime = bakedInputRuntime;
|
|
6
6
|
const graphql_1 = require("graphql");
|
|
7
|
+
const global_js_1 = require("../global.js");
|
|
7
8
|
const step_js_1 = require("../step.js");
|
|
8
9
|
const applyInput_js_1 = require("./applyInput.js");
|
|
9
|
-
const index_js_1 = require("./index.js");
|
|
10
10
|
class BakedInputStep extends step_js_1.UnbatchedStep {
|
|
11
11
|
static { this.$$export = {
|
|
12
12
|
moduleName: "grafast",
|
|
@@ -43,7 +43,7 @@ function bakedInput(inputType, $value) {
|
|
|
43
43
|
((0, graphql_1.isInputObjectType)(nullableInputType) &&
|
|
44
44
|
typeof nullableInputType.extensions?.grafast?.baked === "function")) {
|
|
45
45
|
// Ooo, we're fancy! Do the thing!
|
|
46
|
-
return (0,
|
|
46
|
+
return (0, global_js_1.operationPlan)().withRootLayerPlan(() => new BakedInputStep(nullableInputType, $value));
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
// Nothing special, we just return the input.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Maybe, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
2
|
+
import type { Step } from "../step.js";
|
|
3
|
+
import { UnbatchedStep } from "../step.js";
|
|
4
|
+
export declare class CoalesceStep<T> extends UnbatchedStep<T | null> {
|
|
5
|
+
static $$export: {
|
|
6
|
+
moduleName: string;
|
|
7
|
+
exportName: string;
|
|
8
|
+
};
|
|
9
|
+
isSyncAndSafe: boolean;
|
|
10
|
+
constructor(steps: ReadonlyArray<Step<Maybe<T>>>);
|
|
11
|
+
unbatchedExecute(_info: UnbatchedExecutionExtra, ...values: ReadonlyArray<T | null>): NonNullable<T> | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function coalesce<T>(steps: ReadonlyArray<Step<Maybe<T>>>): CoalesceStep<T>;
|
|
14
|
+
export declare function coalesce<T>(...steps: ReadonlyArray<Step<Maybe<T>>>): CoalesceStep<T>;
|
|
15
|
+
//# sourceMappingURL=coalesce.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoalesceStep = void 0;
|
|
4
|
+
exports.coalesce = coalesce;
|
|
5
|
+
const constants_js_1 = require("../constants.js");
|
|
6
|
+
const step_js_1 = require("../step.js");
|
|
7
|
+
class CoalesceStep extends step_js_1.UnbatchedStep {
|
|
8
|
+
static { this.$$export = {
|
|
9
|
+
moduleName: "grafast",
|
|
10
|
+
exportName: "CoalesceStep",
|
|
11
|
+
}; }
|
|
12
|
+
constructor(steps) {
|
|
13
|
+
super();
|
|
14
|
+
this.isSyncAndSafe = true;
|
|
15
|
+
this.allowMultipleOptimizations = true;
|
|
16
|
+
for (const step of steps) {
|
|
17
|
+
this.addDataDependency({
|
|
18
|
+
step,
|
|
19
|
+
acceptFlags: constants_js_1.FLAG_INHIBITED | constants_js_1.FLAG_NULL,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
unbatchedExecute(_info, ...values) {
|
|
24
|
+
return values.find((v) => v != null) ?? null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.CoalesceStep = CoalesceStep;
|
|
28
|
+
function coalesce(...input) {
|
|
29
|
+
if (Array.isArray(input[0])) {
|
|
30
|
+
return new CoalesceStep(input[0]);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return new CoalesceStep(input);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=coalesce.js.map
|
package/dist/steps/constant.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConstantStep = void 0;
|
|
4
4
|
exports.constant = constant;
|
|
5
|
+
const global_js_1 = require("../global.js");
|
|
5
6
|
const inspect_js_1 = require("../inspect.js");
|
|
6
7
|
const step_js_1 = require("../step.js");
|
|
7
8
|
const utils_js_1 = require("../utils.js");
|
|
8
|
-
const index_js_1 = require("./index.js");
|
|
9
9
|
/**
|
|
10
10
|
* Converts a constant value (e.g. a string/number/etc) into a plan
|
|
11
11
|
*/
|
|
@@ -130,19 +130,21 @@ function constant(data, isSecret) {
|
|
|
130
130
|
}
|
|
131
131
|
return constant(data[0], false);
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
return (0, global_js_1.operationPlan)().withRootLayerPlan(() => {
|
|
134
|
+
const opPlan = (0, global_js_1.operationPlan)();
|
|
135
|
+
const makeConst = () => new ConstantStep(data, isSecret);
|
|
136
|
+
const t = typeof data;
|
|
137
|
+
if (data == null ||
|
|
138
|
+
t === "boolean" ||
|
|
139
|
+
t === "string" ||
|
|
140
|
+
t === "number" ||
|
|
141
|
+
t === "symbol") {
|
|
142
|
+
return opPlan.cacheImmutableStep(isSecret ? `constant-secret` : `constant`, data, makeConst);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return makeConst();
|
|
146
|
+
}
|
|
147
|
+
});
|
|
146
148
|
}
|
|
147
149
|
// Have to overwrite the getDepOrConstant method due to circular dependency
|
|
148
150
|
step_js_1.Step.prototype.getDepOrConstant = function (depId, fallback) {
|
package/dist/steps/each.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { Maybe } from "../index.js";
|
|
1
2
|
import type { ListCapableStep, Step } from "../step.js";
|
|
2
|
-
import { __ItemStep } from "./__item.js";
|
|
3
3
|
import type { ConnectionCapableStep, ItemsStep } from "./connection.js";
|
|
4
4
|
import type { __ListTransformStep } from "./listTransform.js";
|
|
5
5
|
/**
|
|
6
6
|
* Transforms a list by wrapping each element in the list with the given mapper.
|
|
7
7
|
*/
|
|
8
|
-
export declare function each<TListStep extends (Step<readonly any[]> & Partial<ConnectionCapableStep<any, any>>) | ConnectionCapableStep<any, any>, TResultItemStep extends Step>(listStep: TListStep, mapper: (itemPlan: ItemsStep<TListStep> extends ListCapableStep<any, any> ? ReturnType<ItemsStep<TListStep>["listItem"]> :
|
|
8
|
+
export declare function each<TListStep extends (Step<readonly any[]> & Partial<ConnectionCapableStep<any, any>>) | ConnectionCapableStep<any, any>, TResultItemStep extends Step>(listStep: TListStep, mapper: (itemPlan: ItemsStep<TListStep> extends ListCapableStep<any, any> ? ReturnType<ItemsStep<TListStep>["listItem"]> : Step<TListStep extends Step<Maybe<ReadonlyArray<infer U>>> ? U : any>) => TResultItemStep): __ListTransformStep<any, any, any, any>;
|
|
9
9
|
//# sourceMappingURL=each.d.ts.map
|
package/dist/steps/first.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { $$deepDepSkip } from "../constants.js";
|
|
1
2
|
import type { ExecutionDetails, GrafastResultsList, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
2
3
|
import type { Step } from "../step.js";
|
|
3
4
|
import { UnbatchedStep } from "../step.js";
|
|
@@ -10,6 +11,7 @@ export declare class FirstStep<TData> extends UnbatchedStep<TData> {
|
|
|
10
11
|
isSyncAndSafe: boolean;
|
|
11
12
|
allowMultipleOptimizations: boolean;
|
|
12
13
|
constructor(parentPlan: Step<ReadonlyArray<TData>> | ConnectionCapableStep<Step<TData>, any>);
|
|
14
|
+
[$$deepDepSkip](): Step;
|
|
13
15
|
execute({ indexMap, values: [values0], }: ExecutionDetails<[ReadonlyArray<TData>]>): GrafastResultsList<TData>;
|
|
14
16
|
unbatchedExecute(_extra: UnbatchedExecutionExtra, list: any[]): any;
|
|
15
17
|
deduplicate(peers: FirstStep<TData>[]): FirstStep<TData>[];
|
package/dist/steps/first.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FirstStep = void 0;
|
|
4
4
|
exports.first = first;
|
|
5
|
+
const constants_js_1 = require("../constants.js");
|
|
5
6
|
const step_js_1 = require("../step.js");
|
|
6
7
|
const connection_js_1 = require("./connection.js");
|
|
7
8
|
const list_js_1 = require("./list.js");
|
|
@@ -14,7 +15,10 @@ class FirstStep extends step_js_1.UnbatchedStep {
|
|
|
14
15
|
super();
|
|
15
16
|
this.isSyncAndSafe = true;
|
|
16
17
|
this.allowMultipleOptimizations = true;
|
|
17
|
-
this.
|
|
18
|
+
this.addStrongDependency((0, connection_js_1.itemsOrStep)(parentPlan));
|
|
19
|
+
}
|
|
20
|
+
[constants_js_1.$$deepDepSkip]() {
|
|
21
|
+
return this.getDepOptions(0).step;
|
|
18
22
|
}
|
|
19
23
|
execute({ indexMap, values: [values0], }) {
|
|
20
24
|
return indexMap((i) => values0.at(i)?.[0]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PlanTypeInfo } from "../interfaces.js";
|
|
2
2
|
import { Step } from "../step.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function graphqlResolveType($stepOrSpecifier: Step, info: PlanTypeInfo): GraphQLResolveTypeStep;
|
|
4
4
|
//# sourceMappingURL=graphqlResolver.d.ts.map
|