grafast 0.1.1-beta.20 → 0.1.1-beta.21
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.js +2 -3
- package/dist/assert.js +2 -3
- package/dist/constraints.js +1 -2
- package/dist/deferred.js +1 -2
- package/dist/dev.js +2 -2
- package/dist/engine/LayerPlan.d.ts +20 -16
- package/dist/engine/LayerPlan.js +5 -10
- package/dist/engine/OperationPlan.d.ts +12 -13
- package/dist/engine/OperationPlan.js +210 -146
- package/dist/engine/OutputPlan.d.ts +4 -4
- package/dist/engine/OutputPlan.js +13 -10
- package/dist/engine/StepTracker.js +11 -2
- package/dist/engine/executeBucket.js +135 -94
- package/dist/engine/executeOutputPlan.js +1 -2
- package/dist/engine/lib/defaultPlanResolver.d.ts +6 -0
- package/dist/engine/lib/defaultPlanResolver.js +11 -0
- package/dist/engine/lib/withGlobalLayerPlan.d.ts +2 -2
- package/dist/engine/lib/withGlobalLayerPlan.js +4 -5
- package/dist/engine/lock.d.ts +3 -3
- package/dist/engine/lock.js +3 -3
- package/dist/error.js +4 -4
- package/dist/establishOperationPlan.js +2 -3
- package/dist/execute.js +3 -4
- package/dist/exportAs.js +2 -3
- package/dist/global.js +2 -3
- package/dist/grafastGraphql.js +2 -3
- package/dist/grafastPrint.js +7 -8
- package/dist/graphqlCollectFields.js +6 -7
- package/dist/graphqlMergeSelectionSets.js +1 -2
- package/dist/index.d.ts +22 -18
- package/dist/index.js +41 -16
- package/dist/input.js +75 -28
- package/dist/inspect.d.ts +9 -4
- package/dist/inspect.js +2 -2
- package/dist/interfaces.d.ts +110 -89
- package/dist/makeGrafastSchema.d.ts +18 -9
- package/dist/makeGrafastSchema.js +64 -30
- package/dist/mermaid.js +53 -14
- package/dist/middleware.js +1 -2
- package/dist/multistep.d.ts +6 -6
- package/dist/multistep.js +6 -7
- package/dist/operationPlan-input.d.ts +5 -4
- package/dist/operationPlan-input.js +131 -399
- package/dist/planJSONInterfaces.d.ts +6 -2
- package/dist/polymorphic.js +4 -5
- package/dist/prepare.js +6 -6
- package/dist/step.d.ts +67 -99
- package/dist/step.js +99 -127
- package/dist/steps/__flag.d.ts +16 -16
- package/dist/steps/__flag.js +9 -6
- package/dist/steps/__inputDefault.d.ts +14 -0
- package/dist/steps/__inputDefault.js +48 -0
- package/dist/steps/__inputDynamicScalar.d.ts +2 -4
- package/dist/steps/__inputDynamicScalar.js +4 -2
- package/dist/steps/__inputList.d.ts +5 -9
- package/dist/steps/__inputList.js +4 -1
- package/dist/steps/__inputObject.d.ts +6 -11
- package/dist/steps/__inputObject.js +13 -3
- package/dist/steps/__inputStaticLeaf.d.ts +2 -4
- package/dist/steps/__inputStaticLeaf.js +3 -1
- package/dist/steps/__item.d.ts +6 -6
- package/dist/steps/__item.js +1 -1
- package/dist/steps/__trackedValue.d.ts +4 -49
- package/dist/steps/__trackedValue.js +24 -6
- package/dist/steps/__value.d.ts +3 -3
- package/dist/steps/__value.js +3 -2
- package/dist/steps/access.d.ts +7 -6
- package/dist/steps/access.js +14 -7
- package/dist/steps/applyInput.d.ts +44 -0
- package/dist/steps/applyInput.js +206 -0
- package/dist/steps/applyTransforms.d.ts +2 -2
- package/dist/steps/applyTransforms.js +7 -5
- package/dist/steps/bakedInput.d.ts +23 -0
- package/dist/steps/bakedInput.js +90 -0
- package/dist/steps/condition.d.ts +5 -5
- package/dist/steps/condition.js +3 -3
- package/dist/steps/connection.d.ts +42 -39
- package/dist/steps/connection.js +51 -35
- package/dist/steps/constant.d.ts +4 -8
- package/dist/steps/constant.js +54 -6
- package/dist/steps/each.d.ts +3 -3
- package/dist/steps/each.js +1 -2
- package/dist/steps/error.d.ts +2 -2
- package/dist/steps/error.js +3 -3
- package/dist/steps/filter.d.ts +3 -2
- package/dist/steps/filter.js +1 -2
- package/dist/steps/first.d.ts +6 -5
- package/dist/steps/first.js +5 -4
- package/dist/steps/graphqlResolver.d.ts +2 -2
- package/dist/steps/graphqlResolver.js +44 -56
- package/dist/steps/groupBy.d.ts +3 -2
- package/dist/steps/groupBy.js +1 -2
- package/dist/steps/index.d.ts +4 -2
- package/dist/steps/index.js +21 -9
- package/dist/steps/lambda.d.ts +5 -5
- package/dist/steps/lambda.js +4 -4
- package/dist/steps/last.d.ts +6 -5
- package/dist/steps/last.js +5 -4
- package/dist/steps/list.d.ts +7 -7
- package/dist/steps/list.js +3 -3
- package/dist/steps/listTransform.d.ts +14 -12
- package/dist/steps/listTransform.js +14 -7
- package/dist/steps/listen.d.ts +6 -8
- package/dist/steps/listen.js +7 -7
- package/dist/steps/load.d.ts +6 -6
- package/dist/steps/load.js +7 -7
- package/dist/steps/node.d.ts +16 -10
- package/dist/steps/node.js +14 -7
- package/dist/steps/object.d.ts +11 -11
- package/dist/steps/object.js +5 -5
- package/dist/steps/partitionByIndex.d.ts +3 -2
- package/dist/steps/partitionByIndex.js +1 -2
- package/dist/steps/polymorphicBranch.d.ts +8 -8
- package/dist/steps/polymorphicBranch.js +4 -4
- package/dist/steps/proxy.d.ts +8 -8
- package/dist/steps/proxy.js +3 -3
- package/dist/steps/remapKeys.d.ts +6 -6
- package/dist/steps/remapKeys.js +3 -3
- package/dist/steps/reverse.d.ts +5 -5
- package/dist/steps/reverse.js +4 -4
- package/dist/steps/setter.d.ts +9 -18
- package/dist/steps/setter.js +24 -14
- package/dist/steps/sideEffect.d.ts +4 -4
- package/dist/steps/sideEffect.js +3 -3
- package/dist/stringifyPayload.js +1 -2
- package/dist/stripAnsi.js +2 -2
- package/dist/subscribe.js +2 -3
- package/dist/timeSource.d.ts +0 -1
- package/dist/utils.d.ts +43 -31
- package/dist/utils.js +97 -61
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { GraphQLInputObjectType } from "graphql";
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { AnyInputStep, NotVariableValueNode, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
3
|
+
import { UnbatchedStep } from "../step.js";
|
|
4
4
|
/**
|
|
5
5
|
* Implements `InputObjectStep`
|
|
6
6
|
*/
|
|
7
|
-
export declare class __InputObjectStep<TInputType extends GraphQLInputObjectType = GraphQLInputObjectType> extends
|
|
7
|
+
export declare class __InputObjectStep<TInputType extends GraphQLInputObjectType = GraphQLInputObjectType> extends UnbatchedStep {
|
|
8
8
|
private inputObjectType;
|
|
9
9
|
private inputValues;
|
|
10
10
|
static $$export: {
|
|
@@ -14,17 +14,12 @@ export declare class __InputObjectStep<TInputType extends GraphQLInputObjectType
|
|
|
14
14
|
isSyncAndSafe: boolean;
|
|
15
15
|
private inputFields;
|
|
16
16
|
constructor(inputObjectType: TInputType, inputValues: NotVariableValueNode | undefined);
|
|
17
|
-
optimize():
|
|
17
|
+
optimize(): import("./constant.js").ConstantStep<null> | this;
|
|
18
18
|
finalize(): void;
|
|
19
19
|
unbatchedExecute(_extra: UnbatchedExecutionExtra, ...values: any[]): any;
|
|
20
|
-
get(attrName: string):
|
|
21
|
-
eval(): any;
|
|
22
|
-
evalIs(value: null | undefined | 0): boolean;
|
|
23
|
-
evalIsEmpty(): boolean;
|
|
24
|
-
evalHas(attrName: string): boolean;
|
|
25
|
-
evalKeys(): ReadonlyArray<keyof TInputType & string> | null;
|
|
20
|
+
get(attrName: string): AnyInputStep;
|
|
26
21
|
}
|
|
27
22
|
export type __InputObjectStepWithDollars<TInputType extends GraphQLInputObjectType = GraphQLInputObjectType> = __InputObjectStep<TInputType> & {
|
|
28
|
-
[key in keyof ReturnType<TInputType["getFields"]> & string as `$${key}`]:
|
|
23
|
+
[key in keyof ReturnType<TInputType["getFields"]> & string as `$${key}`]: AnyInputStep;
|
|
29
24
|
};
|
|
30
25
|
//# sourceMappingURL=__inputObject.d.ts.map
|
|
@@ -12,7 +12,7 @@ const { Kind } = graphql;
|
|
|
12
12
|
/**
|
|
13
13
|
* Implements `InputObjectStep`
|
|
14
14
|
*/
|
|
15
|
-
class __InputObjectStep extends step_js_1.
|
|
15
|
+
class __InputObjectStep extends step_js_1.UnbatchedStep {
|
|
16
16
|
static { this.$$export = {
|
|
17
17
|
moduleName: "grafast",
|
|
18
18
|
exportName: "__InputObjectStep",
|
|
@@ -55,8 +55,11 @@ class __InputObjectStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
55
55
|
if (dependencyIndex == null) {
|
|
56
56
|
throw new Error("inputFieldPlan has gone missing.");
|
|
57
57
|
}
|
|
58
|
+
const teVal = tamedevil_1.default.identifier(`val${dependencyIndex}`);
|
|
58
59
|
return (0, tamedevil_1.default) `\
|
|
59
|
-
|
|
60
|
+
if (${teVal} !== undefined) {
|
|
61
|
+
resultValues${tamedevil_1.default.set(inputFieldName, true)} = ${teVal};
|
|
62
|
+
}`;
|
|
60
63
|
}), "\n")}
|
|
61
64
|
return resultValues;
|
|
62
65
|
})`, (fn) => {
|
|
@@ -72,7 +75,9 @@ class __InputObjectStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
72
75
|
throw new Error("inputFieldPlan has gone missing.");
|
|
73
76
|
}
|
|
74
77
|
const value = values[dependencyIndex];
|
|
75
|
-
|
|
78
|
+
if (value !== undefined) {
|
|
79
|
+
resultValues[inputFieldName] = value;
|
|
80
|
+
}
|
|
76
81
|
}
|
|
77
82
|
return resultValues;
|
|
78
83
|
}
|
|
@@ -83,6 +88,7 @@ class __InputObjectStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
83
88
|
}
|
|
84
89
|
return step;
|
|
85
90
|
}
|
|
91
|
+
/** @internal */
|
|
86
92
|
eval() {
|
|
87
93
|
if (this.inputValues?.kind === "NullValue") {
|
|
88
94
|
return null;
|
|
@@ -94,6 +100,7 @@ class __InputObjectStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
94
100
|
}
|
|
95
101
|
return resultValues;
|
|
96
102
|
}
|
|
103
|
+
/** @internal */
|
|
97
104
|
evalIs(value) {
|
|
98
105
|
if (value === undefined) {
|
|
99
106
|
return this.inputValues === value;
|
|
@@ -108,11 +115,13 @@ class __InputObjectStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
108
115
|
throw new Error("__InputObjectStep cannot evalIs values other than null and undefined currently");
|
|
109
116
|
}
|
|
110
117
|
}
|
|
118
|
+
/** @internal */
|
|
111
119
|
evalIsEmpty() {
|
|
112
120
|
return (this.inputValues?.kind === "ObjectValue" &&
|
|
113
121
|
this.inputValues.fields.length === 0);
|
|
114
122
|
}
|
|
115
123
|
// Written without consulting spec.
|
|
124
|
+
/** @internal */
|
|
116
125
|
evalHas(attrName) {
|
|
117
126
|
if (!this.inputValues) {
|
|
118
127
|
return false;
|
|
@@ -125,6 +134,7 @@ class __InputObjectStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
125
134
|
}
|
|
126
135
|
return !this.inputFields[attrName].step.evalIs(undefined);
|
|
127
136
|
}
|
|
137
|
+
/** @internal */
|
|
128
138
|
evalKeys() {
|
|
129
139
|
if (this.inputValues === undefined) {
|
|
130
140
|
return null;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { BooleanValueNode, EnumValueNode, FloatValueNode, GraphQLLeafType, IntValueNode, NullValueNode, StringValueNode } from "graphql";
|
|
2
|
-
import {
|
|
2
|
+
import { UnbatchedStep } from "../step.js";
|
|
3
3
|
/**
|
|
4
4
|
* Implements `InputStaticLeafStep`
|
|
5
5
|
*
|
|
6
6
|
* @see __InputDynamicScalarStep
|
|
7
7
|
*/
|
|
8
|
-
export declare class __InputStaticLeafStep<TLeaf = any> extends
|
|
8
|
+
export declare class __InputStaticLeafStep<TLeaf = any> extends UnbatchedStep<TLeaf> {
|
|
9
9
|
static $$export: {
|
|
10
10
|
moduleName: string;
|
|
11
11
|
exportName: string;
|
|
@@ -15,7 +15,5 @@ export declare class __InputStaticLeafStep<TLeaf = any> extends UnbatchedExecuta
|
|
|
15
15
|
constructor(inputType: GraphQLLeafType, value: IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | undefined);
|
|
16
16
|
unbatchedExecute(): TLeaf;
|
|
17
17
|
optimize(): import("./constant.js").ConstantStep<any>;
|
|
18
|
-
eval(): TLeaf;
|
|
19
|
-
evalIs(expectedValue: unknown): boolean;
|
|
20
18
|
}
|
|
21
19
|
//# sourceMappingURL=__inputStaticLeaf.d.ts.map
|
|
@@ -11,7 +11,7 @@ const { valueFromAST } = graphql;
|
|
|
11
11
|
*
|
|
12
12
|
* @see __InputDynamicScalarStep
|
|
13
13
|
*/
|
|
14
|
-
class __InputStaticLeafStep extends step_js_1.
|
|
14
|
+
class __InputStaticLeafStep extends step_js_1.UnbatchedStep {
|
|
15
15
|
static { this.$$export = {
|
|
16
16
|
moduleName: "grafast",
|
|
17
17
|
exportName: "__InputStaticLeafStep",
|
|
@@ -32,9 +32,11 @@ class __InputStaticLeafStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
32
32
|
optimize() {
|
|
33
33
|
return (0, constant_js_1.constant)(this.coercedValue, false);
|
|
34
34
|
}
|
|
35
|
+
/** @internal */
|
|
35
36
|
eval() {
|
|
36
37
|
return this.coercedValue;
|
|
37
38
|
}
|
|
39
|
+
/** @internal */
|
|
38
40
|
evalIs(expectedValue) {
|
|
39
41
|
return this.coercedValue === expectedValue;
|
|
40
42
|
}
|
package/dist/steps/__item.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { GrafastResultsList, JSONValue } from "../index.js";
|
|
2
2
|
import { $$deepDepSkip } from "../interfaces.js";
|
|
3
|
-
import type {
|
|
4
|
-
import { $$noExec,
|
|
3
|
+
import type { Step } from "../step.js";
|
|
4
|
+
import { $$noExec, UnbatchedStep } from "../step.js";
|
|
5
5
|
/**
|
|
6
6
|
* An __ItemStep is an internal plan (users must never construct it
|
|
7
7
|
* themselves!) that Grafast uses to refer to an individual item within a list
|
|
8
8
|
* or stream.
|
|
9
9
|
*/
|
|
10
|
-
export declare class __ItemStep<TData> extends
|
|
10
|
+
export declare class __ItemStep<TData> extends UnbatchedStep<TData> {
|
|
11
11
|
readonly depth: number;
|
|
12
12
|
static $$export: {
|
|
13
13
|
moduleName: string;
|
|
@@ -15,11 +15,11 @@ export declare class __ItemStep<TData> extends UnbatchedExecutableStep<TData> {
|
|
|
15
15
|
};
|
|
16
16
|
isSyncAndSafe: boolean;
|
|
17
17
|
[$$noExec]: boolean;
|
|
18
|
-
constructor(parentPlan:
|
|
18
|
+
constructor(parentPlan: Step<TData> | Step<TData[]>, depth?: number);
|
|
19
19
|
toStringMeta(): string;
|
|
20
20
|
planJSONExtra(): Record<string, JSONValue | undefined> | undefined;
|
|
21
|
-
getParentStep():
|
|
22
|
-
[$$deepDepSkip]():
|
|
21
|
+
getParentStep(): Step;
|
|
22
|
+
[$$deepDepSkip](): Step;
|
|
23
23
|
execute(): GrafastResultsList<TData>;
|
|
24
24
|
unbatchedExecute(): TData;
|
|
25
25
|
finalize(): void;
|
package/dist/steps/__item.js
CHANGED
|
@@ -11,7 +11,7 @@ const step_js_1 = require("../step.js");
|
|
|
11
11
|
* themselves!) that Grafast uses to refer to an individual item within a list
|
|
12
12
|
* or stream.
|
|
13
13
|
*/
|
|
14
|
-
class __ItemStep extends step_js_1.
|
|
14
|
+
class __ItemStep extends step_js_1.UnbatchedStep {
|
|
15
15
|
static { this.$$export = {
|
|
16
16
|
moduleName: "grafast",
|
|
17
17
|
exportName: "__ItemStep",
|
|
@@ -2,7 +2,7 @@ import type { GraphQLInputObjectType, GraphQLInputType, VariableDefinitionNode }
|
|
|
2
2
|
import { GraphQLList, GraphQLNonNull } from "graphql";
|
|
3
3
|
import type { Constraint } from "../constraints.js";
|
|
4
4
|
import type { ExecutionDetails, GrafastResultsList, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
5
|
-
import {
|
|
5
|
+
import { UnbatchedStep } from "../step.js";
|
|
6
6
|
import type { __ValueStep } from "./__value.js";
|
|
7
7
|
import type { AccessStep } from "./access.js";
|
|
8
8
|
/**
|
|
@@ -24,7 +24,7 @@ import type { AccessStep } from "./access.js";
|
|
|
24
24
|
* change the query plan, but it can also be used within plan resolvers to
|
|
25
25
|
* branch the logic of a plan based on something in these entities.
|
|
26
26
|
*/
|
|
27
|
-
export declare class __TrackedValueStep<TData = any, TInputType extends GraphQLInputType | ReadonlyArray<VariableDefinitionNode> | undefined = undefined> extends
|
|
27
|
+
export declare class __TrackedValueStep<TData = any, TInputType extends GraphQLInputType | ReadonlyArray<VariableDefinitionNode> | undefined = undefined> extends UnbatchedStep<TData> {
|
|
28
28
|
static $$export: {
|
|
29
29
|
moduleName: string;
|
|
30
30
|
exportName: string;
|
|
@@ -40,7 +40,7 @@ export declare class __TrackedValueStep<TData = any, TInputType extends GraphQLI
|
|
|
40
40
|
* `constraints` relates to).
|
|
41
41
|
*/
|
|
42
42
|
private readonly path;
|
|
43
|
-
static withGraphQLType<TInputType extends GraphQLInputType, TData = any>(value: TData | undefined, valuePlan: __ValueStep<TData> | AccessStep<TData>, constraints: Constraint[], path:
|
|
43
|
+
static withGraphQLType<TInputType extends GraphQLInputType, TData = any>(value: TData | undefined, valuePlan: __ValueStep<TData> | AccessStep<TData>, constraints: Constraint[], path: Array<string | number> | undefined, graphqlType: TInputType): __TrackedValueStepWithDollars<TData, TInputType>;
|
|
44
44
|
private nullableGraphQLType;
|
|
45
45
|
private variableDefinitions;
|
|
46
46
|
execute({ count, values: [values0], }: ExecutionDetails<[TData]>): GrafastResultsList<TData>;
|
|
@@ -54,52 +54,7 @@ export declare class __TrackedValueStep<TData = any, TInputType extends GraphQLI
|
|
|
54
54
|
* Get the entry at the given index in an array.
|
|
55
55
|
*/
|
|
56
56
|
at<TIndex extends keyof TData & number>(index: TIndex): __TrackedValueStepWithDollars<TData[TIndex], TInputType extends GraphQLList<infer U> ? U & GraphQLInputType : TInputType extends GraphQLNonNull<GraphQLList<infer U>> ? U & GraphQLInputType : undefined>;
|
|
57
|
-
|
|
58
|
-
* Evaluates the current value, and adds a constraint to the OpPlan to ensure
|
|
59
|
-
* that all future evaluations of this property will always return the same
|
|
60
|
-
* value.
|
|
61
|
-
*
|
|
62
|
-
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
63
|
-
*
|
|
64
|
-
* **WARNING**: this is the most expensive eval, if you need to eval, prefer evalIs, evalHas, etc instead.
|
|
65
|
-
*/
|
|
66
|
-
eval(): TData | undefined;
|
|
67
|
-
/**
|
|
68
|
-
* Evaluates if the current value is equal to this specific value, and adds a
|
|
69
|
-
* constraint to the OpPlan to ensure that all future evaluations of this
|
|
70
|
-
* check will always return the same (boolean) result.
|
|
71
|
-
*
|
|
72
|
-
* Should only be used on scalars.
|
|
73
|
-
*
|
|
74
|
-
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
75
|
-
*/
|
|
76
|
-
evalIs(expectedValue: unknown): boolean;
|
|
77
|
-
evalIsEmpty(): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Evaluates if the current value is an object with the given key, and adds a
|
|
80
|
-
* constraint to the OpPlan to ensure that all future evaluations of this
|
|
81
|
-
* check will always return the same (boolean) result.
|
|
82
|
-
*
|
|
83
|
-
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
84
|
-
*/
|
|
85
|
-
evalHas(key: string): boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Evaluates the keys of the current value, and adds a
|
|
88
|
-
* constraint to the OpPlan to ensure that all future evaluations of this
|
|
89
|
-
* check will always return the same result.
|
|
90
|
-
*
|
|
91
|
-
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
92
|
-
*/
|
|
93
|
-
evalKeys(): ReadonlyArray<keyof TData & string> | null;
|
|
94
|
-
/**
|
|
95
|
-
* Evaluates the length of the current value (assumed to be an array), and
|
|
96
|
-
* adds a constraint to the OpPlan to ensure that all future values will have
|
|
97
|
-
* the same length.
|
|
98
|
-
*
|
|
99
|
-
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
100
|
-
*/
|
|
101
|
-
evalLength(): number | null;
|
|
102
|
-
optimize(): import("../step.js").ExecutableStep<any>;
|
|
57
|
+
optimize(): import("../step.js").Step<any> | import("./__flag.js").__FlagStep<import("../step.js").Step<any>>;
|
|
103
58
|
}
|
|
104
59
|
export type __TrackedValueStepWithDollars<TData = any, TInputType extends GraphQLInputType | undefined = undefined> = __TrackedValueStep<TData, TInputType> & (TInputType extends GraphQLInputObjectType ? {
|
|
105
60
|
[key in keyof ReturnType<TInputType["getFields"]> & string as `$${key}`]: __TrackedValueStepWithDollars<TData extends {
|
|
@@ -23,20 +23,21 @@ const step_js_1 = require("../step.js");
|
|
|
23
23
|
* change the query plan, but it can also be used within plan resolvers to
|
|
24
24
|
* branch the logic of a plan based on something in these entities.
|
|
25
25
|
*/
|
|
26
|
-
class __TrackedValueStep extends step_js_1.
|
|
26
|
+
class __TrackedValueStep extends step_js_1.UnbatchedStep {
|
|
27
27
|
static { this.$$export = {
|
|
28
28
|
moduleName: "grafast",
|
|
29
29
|
exportName: "__TrackedValueStep",
|
|
30
30
|
}; }
|
|
31
31
|
static withGraphQLType(value, valuePlan, constraints, path = [], graphqlType) {
|
|
32
|
-
return new __TrackedValueStep(value, valuePlan, constraints, path, graphqlType);
|
|
32
|
+
return (0, index_js_1.operationPlan)().withRootLayerPlan(() => new __TrackedValueStep(value, valuePlan, constraints, path, true, graphqlType));
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
37
|
-
constructor(value, valuePlan, constraints, path = [], graphqlTypeOrVariableDefinitions) {
|
|
37
|
+
constructor(value, valuePlan, constraints, path = [], isImmutable, graphqlTypeOrVariableDefinitions) {
|
|
38
38
|
super();
|
|
39
39
|
this.isSyncAndSafe = true;
|
|
40
|
+
this._isImmutable = isImmutable;
|
|
40
41
|
this.addDependency(valuePlan);
|
|
41
42
|
this.value = value;
|
|
42
43
|
this.constraints = constraints;
|
|
@@ -90,7 +91,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
90
91
|
return v;
|
|
91
92
|
}
|
|
92
93
|
getValuePlan() {
|
|
93
|
-
return this.getDep(0);
|
|
94
|
+
return this.getDep(0, true);
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
96
97
|
* Get the named property of an object.
|
|
@@ -133,8 +134,11 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
133
134
|
const type = getType(def.type);
|
|
134
135
|
return __TrackedValueStep.withGraphQLType(newValue, newValuePlan, constraints, newPath, type);
|
|
135
136
|
}
|
|
137
|
+
else if (this._isImmutable) {
|
|
138
|
+
return this.operationPlan.withRootLayerPlan(() => new __TrackedValueStep(newValue, newValuePlan, constraints, newPath, this._isImmutable));
|
|
139
|
+
}
|
|
136
140
|
else {
|
|
137
|
-
return new __TrackedValueStep(newValue, newValuePlan, constraints, newPath);
|
|
141
|
+
return new __TrackedValueStep(newValue, newValuePlan, constraints, newPath, this._isImmutable);
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
/**
|
|
@@ -153,8 +157,11 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
153
157
|
throw new Error(`'${this.nullableGraphQLType}' is not a list type, cannot access array index '${index}' on it`);
|
|
154
158
|
}
|
|
155
159
|
}
|
|
160
|
+
else if (this._isImmutable) {
|
|
161
|
+
return this.operationPlan.withRootLayerPlan(() => new __TrackedValueStep(newValue, newValuePlan, constraints, newPath, this._isImmutable));
|
|
162
|
+
}
|
|
156
163
|
else {
|
|
157
|
-
return new __TrackedValueStep(newValue, newValuePlan, constraints, newPath);
|
|
164
|
+
return new __TrackedValueStep(newValue, newValuePlan, constraints, newPath, this._isImmutable);
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
167
|
/**
|
|
@@ -165,6 +172,8 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
165
172
|
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
166
173
|
*
|
|
167
174
|
* **WARNING**: this is the most expensive eval, if you need to eval, prefer evalIs, evalHas, etc instead.
|
|
175
|
+
*
|
|
176
|
+
* @internal
|
|
168
177
|
*/
|
|
169
178
|
eval() {
|
|
170
179
|
const { path, value } = this;
|
|
@@ -183,6 +192,8 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
183
192
|
* Should only be used on scalars.
|
|
184
193
|
*
|
|
185
194
|
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
195
|
+
*
|
|
196
|
+
* @internal
|
|
186
197
|
*/
|
|
187
198
|
evalIs(expectedValue) {
|
|
188
199
|
const { value, path } = this;
|
|
@@ -195,6 +206,7 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
195
206
|
});
|
|
196
207
|
return pass;
|
|
197
208
|
}
|
|
209
|
+
/** @internal */
|
|
198
210
|
evalIsEmpty() {
|
|
199
211
|
const { value, path } = this;
|
|
200
212
|
const isEmpty = typeof value === "object" &&
|
|
@@ -213,6 +225,8 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
213
225
|
* check will always return the same (boolean) result.
|
|
214
226
|
*
|
|
215
227
|
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
228
|
+
*
|
|
229
|
+
* @internal
|
|
216
230
|
*/
|
|
217
231
|
evalHas(key) {
|
|
218
232
|
const { value, path } = this;
|
|
@@ -237,6 +251,8 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
237
251
|
* check will always return the same result.
|
|
238
252
|
*
|
|
239
253
|
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
254
|
+
*
|
|
255
|
+
* @internal
|
|
240
256
|
*/
|
|
241
257
|
evalKeys() {
|
|
242
258
|
const { value, path } = this;
|
|
@@ -277,6 +293,8 @@ class __TrackedValueStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
277
293
|
* the same length.
|
|
278
294
|
*
|
|
279
295
|
* **WARNING**: avoid using this where possible, it causes OpPlans to split.
|
|
296
|
+
*
|
|
297
|
+
* @internal
|
|
280
298
|
*/
|
|
281
299
|
evalLength() {
|
|
282
300
|
const { value, path } = this;
|
package/dist/steps/__value.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { GrafastResultsList } from "../index.js";
|
|
2
|
-
import { $$noExec,
|
|
2
|
+
import { $$noExec, Step } from "../step.js";
|
|
3
3
|
import type { AccessStep } from "./access.js";
|
|
4
4
|
/**
|
|
5
5
|
* Implements `__ValueStep(operationPlan)` which is never executed; it's purely
|
|
6
6
|
* internal - we populate the value as part of the algorithm - see
|
|
7
7
|
* `GetValueStepId` and `PopulateValueStep`.
|
|
8
8
|
*/
|
|
9
|
-
export declare class __ValueStep<TData> extends
|
|
9
|
+
export declare class __ValueStep<TData> extends Step<TData> {
|
|
10
10
|
static $$export: {
|
|
11
11
|
moduleName: string;
|
|
12
12
|
exportName: string;
|
|
13
13
|
};
|
|
14
14
|
isSyncAndSafe: boolean;
|
|
15
15
|
[$$noExec]: boolean;
|
|
16
|
-
constructor();
|
|
16
|
+
constructor(isImmutable: boolean);
|
|
17
17
|
toStringMeta(): string | null;
|
|
18
18
|
execute(): GrafastResultsList<TData>;
|
|
19
19
|
get<TAttr extends keyof TData>(attrName: TAttr): AccessStep<TData[TAttr]>;
|
package/dist/steps/__value.js
CHANGED
|
@@ -9,16 +9,17 @@ const access_js_1 = require("./access.js");
|
|
|
9
9
|
* internal - we populate the value as part of the algorithm - see
|
|
10
10
|
* `GetValueStepId` and `PopulateValueStep`.
|
|
11
11
|
*/
|
|
12
|
-
class __ValueStep extends step_js_1.
|
|
12
|
+
class __ValueStep extends step_js_1.Step {
|
|
13
13
|
static { _a = step_js_1.$$noExec; }
|
|
14
14
|
static { this.$$export = {
|
|
15
15
|
moduleName: "grafast",
|
|
16
16
|
exportName: "__ValueStep",
|
|
17
17
|
}; }
|
|
18
|
-
constructor() {
|
|
18
|
+
constructor(isImmutable) {
|
|
19
19
|
super();
|
|
20
20
|
this.isSyncAndSafe = true;
|
|
21
21
|
this[_a] = true;
|
|
22
|
+
this._isImmutable = isImmutable;
|
|
22
23
|
}
|
|
23
24
|
toStringMeta() {
|
|
24
25
|
switch (this) {
|
package/dist/steps/access.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UnbatchedExecutionExtra } from "../interfaces.js";
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { Step } from "../step.js";
|
|
3
|
+
import { UnbatchedStep } from "../step.js";
|
|
4
4
|
/**
|
|
5
5
|
* Accesses a (potentially nested) property from the result of a plan.
|
|
6
6
|
*
|
|
@@ -9,8 +9,8 @@ import { UnbatchedExecutableStep } from "../step.js";
|
|
|
9
9
|
* preferably where the objects have null prototypes, and be sure to adhere to
|
|
10
10
|
* the naming conventions detailed in assertSafeToAccessViaBraces.
|
|
11
11
|
*/
|
|
12
|
-
export declare class AccessStep<TData> extends
|
|
13
|
-
readonly fallback?: any;
|
|
12
|
+
export declare class AccessStep<TData> extends UnbatchedStep<TData> {
|
|
13
|
+
readonly fallback?: any | undefined;
|
|
14
14
|
static $$export: {
|
|
15
15
|
moduleName: string;
|
|
16
16
|
exportName: string;
|
|
@@ -19,8 +19,9 @@ export declare class AccessStep<TData> extends UnbatchedExecutableStep<TData> {
|
|
|
19
19
|
allowMultipleOptimizations: boolean;
|
|
20
20
|
readonly path: (string | number | symbol)[];
|
|
21
21
|
private readonly hasSymbols;
|
|
22
|
-
constructor(parentPlan:
|
|
22
|
+
constructor(parentPlan: Step<unknown>, path: (string | number | symbol)[], fallback?: any | undefined);
|
|
23
23
|
toStringMeta(): string;
|
|
24
|
+
getParentStep(): Step<any> | import("./__flag.js").__FlagStep<Step<any>>;
|
|
24
25
|
/**
|
|
25
26
|
* Get the named property of an object.
|
|
26
27
|
*/
|
|
@@ -38,5 +39,5 @@ export declare class AccessStep<TData> extends UnbatchedExecutableStep<TData> {
|
|
|
38
39
|
* Access the property at path `path` in the value returned from `parentPlan`,
|
|
39
40
|
* falling back to `fallback` if it were null-ish.
|
|
40
41
|
*/
|
|
41
|
-
export declare function access<TData>(parentPlan:
|
|
42
|
+
export declare function access<TData>(parentPlan: Step<unknown>, rawPath?: (string | number | symbol)[] | string | number | symbol, fallback?: any): AccessStep<TData>;
|
|
42
43
|
//# sourceMappingURL=access.d.ts.map
|
package/dist/steps/access.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AccessStep = exports.expressionSymbol = void 0;
|
|
4
|
+
exports.access = access;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
7
|
const tamedevil_1 = tslib_1.__importDefault(require("tamedevil"));
|
|
@@ -108,7 +109,7 @@ return (_meta, value) => value?.${tamedevil_1.default.join(access, "?.")}${fallb
|
|
|
108
109
|
* preferably where the objects have null prototypes, and be sure to adhere to
|
|
109
110
|
* the naming conventions detailed in assertSafeToAccessViaBraces.
|
|
110
111
|
*/
|
|
111
|
-
class AccessStep extends step_js_1.
|
|
112
|
+
class AccessStep extends step_js_1.UnbatchedStep {
|
|
112
113
|
static { this.$$export = {
|
|
113
114
|
moduleName: "grafast",
|
|
114
115
|
exportName: "AccessStep",
|
|
@@ -118,6 +119,7 @@ class AccessStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
118
119
|
this.fallback = fallback;
|
|
119
120
|
this.isSyncAndSafe = true;
|
|
120
121
|
this.allowMultipleOptimizations = true;
|
|
122
|
+
this._isImmutable = parentPlan._isImmutable;
|
|
121
123
|
this.path = path;
|
|
122
124
|
this.hasSymbols = this.path.some((k) => typeof k === "symbol");
|
|
123
125
|
this.peerKey =
|
|
@@ -127,9 +129,10 @@ class AccessStep extends step_js_1.UnbatchedExecutableStep {
|
|
|
127
129
|
this.addDependency(parentPlan);
|
|
128
130
|
}
|
|
129
131
|
toStringMeta() {
|
|
130
|
-
return `${chalk_1.default.bold.yellow(String(this.
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
return `${chalk_1.default.bold.yellow(String(this.getDepOptions(0).step.id))}.${this.path.map((p) => String(p)).join(".")}`;
|
|
133
|
+
}
|
|
134
|
+
getParentStep() {
|
|
135
|
+
return this.getDep(0);
|
|
133
136
|
}
|
|
134
137
|
/**
|
|
135
138
|
* Get the named property of an object.
|
|
@@ -201,9 +204,13 @@ function access(parentPlan, rawPath, fallback) {
|
|
|
201
204
|
if (typeof fallback === "undefined" &&
|
|
202
205
|
!path.some((k) => typeof k === "symbol")) {
|
|
203
206
|
const pathKey = (0, utils_js_1.digestKeys)(path);
|
|
204
|
-
|
|
207
|
+
if (parentPlan._isImmutable) {
|
|
208
|
+
return parentPlan.operationPlan.withRootLayerPlan(() => parentPlan.operationPlan.cacheStep(parentPlan, "GrafastInternal:access()", pathKey, () => new AccessStep(parentPlan, path)));
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
return parentPlan.operationPlan.cacheStep(parentPlan, "GrafastInternal:access()", pathKey, () => new AccessStep(parentPlan, path));
|
|
212
|
+
}
|
|
205
213
|
}
|
|
206
214
|
return new AccessStep(parentPlan, path, fallback);
|
|
207
215
|
}
|
|
208
|
-
exports.access = access;
|
|
209
216
|
//# sourceMappingURL=access.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { GraphQLInputType, GraphQLSchema } from "graphql";
|
|
2
|
+
import type { AnyInputStep, UnbatchedExecutionExtra } from "../interfaces.js";
|
|
3
|
+
import type { Step } from "../step.js";
|
|
4
|
+
import { UnbatchedStep } from "../step.js";
|
|
5
|
+
import { ConstantStep } from "./index.js";
|
|
6
|
+
export declare class ApplyInputStep<TParent extends object = any, TTarget extends object = TParent> extends UnbatchedStep<(arg: TParent) => void> {
|
|
7
|
+
private inputType;
|
|
8
|
+
private getTargetFromParent;
|
|
9
|
+
static $$export: {
|
|
10
|
+
moduleName: string;
|
|
11
|
+
exportName: string;
|
|
12
|
+
};
|
|
13
|
+
isSyncAndSafe: boolean;
|
|
14
|
+
allowMultipleOptimizations: boolean;
|
|
15
|
+
valueDepId: 0;
|
|
16
|
+
constructor(inputType: GraphQLInputType, $value: AnyInputStep, getTargetFromParent: ((parent: TParent, inputValue: any) => TTarget | undefined | (() => TTarget)) | undefined);
|
|
17
|
+
deduplicate(peers: readonly ApplyInputStep[]): ApplyInputStep<any, any>[];
|
|
18
|
+
optimize(): this | ConstantStep<(parent: TParent) => void>;
|
|
19
|
+
unbatchedExecute(extra: UnbatchedExecutionExtra, value: any): (parentThing: TParent) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function inputArgsApply<TArg extends object, TTarget extends object = TArg>(schema: GraphQLSchema, inputType: GraphQLInputType, parent: TArg, inputValue: unknown, getTargetFromParent: ((parent: TArg, inputValue: any) => TTarget | undefined | (() => TTarget)) | undefined): void;
|
|
22
|
+
export declare function applyInput<TParent extends object = any, TTarget extends object = TParent>(inputType: GraphQLInputType, $value: AnyInputStep, getTargetFromParent?: (parent: TParent, inputValue: any) => TTarget | undefined): ConstantStep<(parent: TParent) => void> | ApplyInputStep<TParent, TTarget>;
|
|
23
|
+
/**
|
|
24
|
+
* Modifiers modify their parent (which may be another modifier or anything
|
|
25
|
+
* else). First they gather all the requirements from their children (if any)
|
|
26
|
+
* being applied to them, then they apply themselves to their parent. This
|
|
27
|
+
* application is done through the `apply()` method.
|
|
28
|
+
*/
|
|
29
|
+
export declare abstract class Modifier<TParent> {
|
|
30
|
+
protected readonly parent: TParent;
|
|
31
|
+
static $$export: any;
|
|
32
|
+
constructor(parent: TParent);
|
|
33
|
+
/**
|
|
34
|
+
* In this method, you should apply the changes to your `this.parent` plan
|
|
35
|
+
*/
|
|
36
|
+
abstract apply(): void;
|
|
37
|
+
}
|
|
38
|
+
export declare function isModifier<TParent>(plan: any): plan is Modifier<TParent>;
|
|
39
|
+
export declare function assertModifier<TParent>(plan: any, pathDescription: string): asserts plan is Modifier<TParent>;
|
|
40
|
+
export type ApplyableExecutableStep<TArg extends object = any, TData = any> = Step<TData> & {
|
|
41
|
+
apply($apply: Step<(arg: TArg) => void>): void;
|
|
42
|
+
};
|
|
43
|
+
export declare function isApplyableStep<TArg extends object = any, TData = any>(s: Step<TData>): s is ApplyableExecutableStep<TArg, TData>;
|
|
44
|
+
//# sourceMappingURL=applyInput.d.ts.map
|