grafast 0.1.1-beta.2 → 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/README.md +2 -3
- package/dist/args.d.ts +4 -7
- package/dist/args.js +53 -38
- package/dist/assert.js +2 -3
- package/dist/bucket.d.ts +1 -89
- package/dist/config.d.ts +0 -17
- package/dist/config.js +1 -95
- package/dist/constraints.d.ts +15 -1
- package/dist/constraints.js +41 -3
- package/dist/deferred.js +1 -2
- package/dist/dev.d.ts +1 -4
- package/dist/dev.js +18 -3
- package/dist/engine/LayerPlan.d.ts +21 -111
- package/dist/engine/LayerPlan.js +196 -78
- package/dist/engine/OperationPlan.d.ts +30 -104
- package/dist/engine/OperationPlan.js +763 -471
- package/dist/engine/OutputPlan.d.ts +9 -20
- package/dist/engine/OutputPlan.js +432 -444
- package/dist/engine/StepTracker.d.ts +1 -95
- package/dist/engine/StepTracker.js +94 -20
- package/dist/engine/executeBucket.d.ts +5 -7
- package/dist/engine/executeBucket.js +646 -244
- package/dist/engine/executeOutputPlan.d.ts +0 -53
- package/dist/engine/executeOutputPlan.js +7 -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 -0
- package/dist/engine/lib/withGlobalLayerPlan.js +7 -4
- package/dist/engine/lock.d.ts +4 -0
- package/dist/engine/lock.js +82 -0
- package/dist/envelop.js +5 -4
- package/dist/error.d.ts +18 -49
- package/dist/error.js +50 -39
- package/dist/establishOperationPlan.js +57 -42
- package/dist/execute.d.ts +5 -4
- package/dist/execute.js +31 -15
- package/dist/exportAs.d.ts +1 -18
- package/dist/exportAs.js +2 -3
- package/dist/global.js +2 -3
- package/dist/grafastGraphql.d.ts +6 -1
- package/dist/grafastGraphql.js +35 -16
- package/dist/grafastPrint.d.ts +3 -0
- package/dist/grafastPrint.js +67 -6
- package/dist/graphqlCollectFields.d.ts +7 -34
- package/dist/graphqlCollectFields.js +24 -13
- package/dist/graphqlMergeSelectionSets.js +1 -2
- package/dist/index.d.ts +44 -29
- package/dist/index.js +91 -18
- package/dist/input.d.ts +1 -9
- package/dist/input.js +75 -28
- package/dist/inspect.d.ts +9 -3
- package/dist/inspect.js +3 -3
- package/dist/interfaces.d.ts +238 -93
- package/dist/interfaces.js +20 -3
- package/dist/makeGrafastSchema.d.ts +21 -9
- package/dist/makeGrafastSchema.js +353 -133
- package/dist/mermaid.d.ts +0 -17
- package/dist/mermaid.js +131 -19
- package/dist/middleware.d.ts +7 -0
- package/dist/middleware.js +24 -0
- package/dist/multistep.d.ts +19 -0
- package/dist/multistep.js +54 -0
- package/dist/operationPlan-input.d.ts +5 -4
- package/dist/operationPlan-input.js +140 -368
- package/dist/planJSONInterfaces.d.ts +12 -2
- package/dist/polymorphic.js +4 -5
- package/dist/prepare.d.ts +1 -7
- package/dist/prepare.js +100 -74
- package/dist/step.d.ts +118 -172
- package/dist/step.js +262 -183
- package/dist/steps/__flag.d.ts +65 -0
- package/dist/steps/__flag.js +261 -0
- package/dist/steps/__inputDefault.d.ts +14 -0
- package/dist/steps/__inputDefault.js +48 -0
- package/dist/steps/__inputDynamicScalar.d.ts +4 -6
- 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 +7 -11
- package/dist/steps/__inputObject.js +49 -3
- package/dist/steps/__inputStaticLeaf.d.ts +2 -4
- package/dist/steps/__inputStaticLeaf.js +3 -1
- package/dist/steps/__item.d.ts +10 -12
- package/dist/steps/__item.js +8 -2
- package/dist/steps/__trackedValue.d.ts +7 -55
- package/dist/steps/__trackedValue.js +69 -8
- package/dist/steps/__value.d.ts +5 -4
- package/dist/steps/__value.js +5 -4
- package/dist/steps/access.d.ts +10 -10
- package/dist/steps/access.js +50 -17
- package/dist/steps/applyInput.d.ts +44 -0
- package/dist/steps/applyInput.js +206 -0
- package/dist/steps/applyTransforms.d.ts +2 -25
- package/dist/steps/applyTransforms.js +53 -31
- package/dist/steps/bakedInput.d.ts +23 -0
- package/dist/steps/bakedInput.js +90 -0
- package/dist/steps/condition.d.ts +31 -0
- package/dist/steps/condition.js +94 -0
- package/dist/steps/connection.d.ts +56 -42
- package/dist/steps/connection.js +97 -44
- package/dist/steps/constant.d.ts +7 -7
- package/dist/steps/constant.js +86 -7
- package/dist/steps/each.d.ts +3 -3
- package/dist/steps/each.js +2 -3
- package/dist/steps/error.d.ts +4 -4
- package/dist/steps/error.js +7 -6
- package/dist/steps/filter.d.ts +3 -2
- package/dist/steps/filter.js +1 -2
- package/dist/steps/first.d.ts +10 -9
- package/dist/steps/first.js +9 -13
- package/dist/steps/graphqlResolver.d.ts +3 -76
- package/dist/steps/graphqlResolver.js +89 -72
- package/dist/steps/groupBy.d.ts +3 -2
- package/dist/steps/groupBy.js +1 -2
- package/dist/steps/index.d.ts +12 -3
- package/dist/steps/index.js +48 -6
- package/dist/steps/lambda.d.ts +9 -9
- package/dist/steps/lambda.js +18 -9
- package/dist/steps/last.d.ts +9 -8
- package/dist/steps/last.js +7 -6
- package/dist/steps/list.d.ts +20 -9
- package/dist/steps/list.js +56 -13
- package/dist/steps/listTransform.d.ts +18 -22
- package/dist/steps/listTransform.js +58 -27
- package/dist/steps/listen.d.ts +6 -11
- package/dist/steps/listen.js +14 -16
- package/dist/steps/load.d.ts +42 -33
- package/dist/steps/load.js +60 -27
- package/dist/steps/node.d.ts +17 -10
- package/dist/steps/node.js +18 -6
- package/dist/steps/object.d.ts +33 -27
- package/dist/steps/object.js +53 -32
- package/dist/steps/partitionByIndex.d.ts +3 -2
- package/dist/steps/partitionByIndex.js +1 -2
- package/dist/steps/polymorphicBranch.d.ts +27 -0
- package/dist/steps/polymorphicBranch.js +62 -0
- package/dist/steps/proxy.d.ts +11 -12
- package/dist/steps/proxy.js +8 -5
- package/dist/steps/remapKeys.d.ts +10 -10
- package/dist/steps/remapKeys.js +14 -7
- package/dist/steps/reverse.d.ts +8 -8
- package/dist/steps/reverse.js +10 -7
- package/dist/steps/setter.d.ts +9 -18
- package/dist/steps/setter.js +24 -14
- package/dist/steps/sideEffect.d.ts +28 -0
- package/dist/steps/sideEffect.js +44 -0
- package/dist/stringifyPayload.js +1 -2
- package/dist/stripAnsi.js +2 -2
- package/dist/subscribe.d.ts +7 -1
- package/dist/subscribe.js +24 -9
- package/dist/thereCanBeOnlyOne.js +1 -1
- package/dist/timeSource.d.ts +0 -1
- package/dist/utils.d.ts +56 -55
- package/dist/utils.js +179 -59
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -8
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { FragmentDefinitionNode, GraphQLFieldMap, GraphQLObjectType, GraphQLSchema, GraphQLUnionType, OperationDefinitionNode } from "graphql";
|
|
2
2
|
import type { Constraint } from "../constraints.js";
|
|
3
3
|
import type { SelectionSetDigest } from "../graphqlCollectFields.js";
|
|
4
|
-
import type { GrafastPlanJSON
|
|
5
|
-
import {
|
|
4
|
+
import type { GrafastPlanJSON } from "../index.js";
|
|
5
|
+
import { Step } from "../index.js";
|
|
6
6
|
import { $$timeout, $$ts } from "../interfaces.js";
|
|
7
7
|
import type { LayerPlanReasonSubroutine } from "./LayerPlan.js";
|
|
8
8
|
import { LayerPlan } from "./LayerPlan.js";
|
|
9
9
|
import { OutputPlan } from "./OutputPlan.js";
|
|
10
|
-
import { StepTracker } from "./StepTracker.js";
|
|
11
10
|
export declare const POLYMORPHIC_ROOT_PATH: null;
|
|
12
11
|
export declare const POLYMORPHIC_ROOT_PATHS: ReadonlySet<string> | null;
|
|
13
|
-
/** @
|
|
12
|
+
/** Beware: the list of phases may change over time... @experimental */
|
|
14
13
|
export type OperationPlanPhase = "init" | "plan" | "validate" | "optimize" | "finalize" | "ready";
|
|
15
14
|
export interface MetaByMetaKey {
|
|
16
15
|
[metaKey: string | number | symbol]: Record<string, any>;
|
|
@@ -49,62 +48,12 @@ export declare class OperationPlan {
|
|
|
49
48
|
* 7. ready
|
|
50
49
|
*
|
|
51
50
|
* Once in 'ready' state we can execute the plan.
|
|
52
|
-
*
|
|
53
|
-
* @internal
|
|
54
51
|
*/
|
|
55
52
|
phase: OperationPlanPhase;
|
|
56
53
|
/**
|
|
57
54
|
* Gets updated as we work our way through the plan, useful for making errors more helpful.
|
|
58
55
|
*/
|
|
59
56
|
loc: string[] | null;
|
|
60
|
-
/** @internal */
|
|
61
|
-
rootLayerPlan: LayerPlan;
|
|
62
|
-
/**
|
|
63
|
-
* Assigned during OperationPlan.planOperation(), guaranteed to exist after
|
|
64
|
-
* initialization.
|
|
65
|
-
*
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
rootOutputPlan: OutputPlan;
|
|
69
|
-
private modifierStepCount;
|
|
70
|
-
private modifierDepthCount;
|
|
71
|
-
private modifierSteps;
|
|
72
|
-
/** @internal */
|
|
73
|
-
readonly stepTracker: StepTracker;
|
|
74
|
-
private maxDeduplicatedStepId;
|
|
75
|
-
private maxValidatedStepId;
|
|
76
|
-
/** Constraints based on evaluating variables. @internal */
|
|
77
|
-
readonly variableValuesConstraints: Constraint[];
|
|
78
|
-
/** Stores the actual variableValues. @internal */
|
|
79
|
-
readonly variableValuesStep: __ValueStep<{
|
|
80
|
-
[key: string]: any;
|
|
81
|
-
}>;
|
|
82
|
-
/** A step for accessing variableValues in a tracked manner (allowing eval). @internal */
|
|
83
|
-
readonly trackedVariableValuesStep: __TrackedValueStep<{
|
|
84
|
-
[key: string]: any;
|
|
85
|
-
}>;
|
|
86
|
-
/** Constraints based on evaluating context. @internal */
|
|
87
|
-
readonly contextConstraints: Constraint[];
|
|
88
|
-
/** Stores the actual value of the context. @internal */
|
|
89
|
-
readonly contextStep: __ValueStep<Grafast.Context>;
|
|
90
|
-
/** Allows accessing context in a tracked manner (allowing eval). @internal */
|
|
91
|
-
readonly trackedContextStep: __TrackedValueStep<{
|
|
92
|
-
[key: string]: any;
|
|
93
|
-
}>;
|
|
94
|
-
/** Constraints based on evaluating rootValue. @internal */
|
|
95
|
-
readonly rootValueConstraints: Constraint[];
|
|
96
|
-
/** Stores the actual value of rootValue. @internal */
|
|
97
|
-
readonly rootValueStep: __ValueStep<any>;
|
|
98
|
-
/** Allows accessing rootValue in a tracked manner (allowing eval). @internal */
|
|
99
|
-
readonly trackedRootValueStep: __TrackedValueStep<any>;
|
|
100
|
-
/** @internal */
|
|
101
|
-
makeMetaByMetaKey: () => MetaByMetaKey;
|
|
102
|
-
/**
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
105
|
-
readonly itemStepIdByListStepId: {
|
|
106
|
-
[listStepId: number]: number | undefined;
|
|
107
|
-
};
|
|
108
57
|
/**
|
|
109
58
|
* If true, then this operation doesn't use (custom) resolvers.
|
|
110
59
|
*/
|
|
@@ -116,42 +65,13 @@ export declare class OperationPlan {
|
|
|
116
65
|
private scalarPlanInfo;
|
|
117
66
|
constructor(schema: GraphQLSchema, operation: OperationDefinitionNode, fragments: {
|
|
118
67
|
[fragmentName: string]: FragmentDefinitionNode;
|
|
119
|
-
}, variableValues: {
|
|
68
|
+
}, variableValuesConstraints: Constraint[], variableValues: {
|
|
120
69
|
[key: string]: any;
|
|
121
|
-
}, context: {
|
|
70
|
+
}, contextConstraints: Constraint[], context: {
|
|
122
71
|
[key: string]: any;
|
|
123
|
-
}, rootValue: any, planningTimeout: number | null);
|
|
72
|
+
}, rootValueConstraints: Constraint[], rootValue: any, planningTimeout: number | null);
|
|
124
73
|
private lap;
|
|
125
74
|
private checkTimeout;
|
|
126
|
-
/**
|
|
127
|
-
* Called by the LayerPlan's constructor when it wants to get a new id to use.
|
|
128
|
-
*
|
|
129
|
-
* @internal
|
|
130
|
-
*/
|
|
131
|
-
addLayerPlan(layerPlan: LayerPlan): number;
|
|
132
|
-
/**
|
|
133
|
-
* Adds a plan to the known steps and returns the number to use as the plan
|
|
134
|
-
* id. ONLY to be used from Step, user code should never call this directly.
|
|
135
|
-
*
|
|
136
|
-
* @internal
|
|
137
|
-
*/
|
|
138
|
-
_addStep(plan: ExecutableStep): number;
|
|
139
|
-
/**
|
|
140
|
-
* Adds a plan to the known steps and returns the number to use as the plan
|
|
141
|
-
* id. ONLY to be used from Step, user code should never call this directly.
|
|
142
|
-
*
|
|
143
|
-
* @internal
|
|
144
|
-
*/
|
|
145
|
-
_addModifierStep(step: ModifierStep<any>): string;
|
|
146
|
-
/** @internal Use plan.getStep(id) instead. */
|
|
147
|
-
getStep: (id: number, requestingStep: ExecutableStep) => ExecutableStep;
|
|
148
|
-
/**
|
|
149
|
-
* Get a plan without specifying who requested it; this disables all the
|
|
150
|
-
* caller checks. Only intended to be called from internal code.
|
|
151
|
-
*
|
|
152
|
-
* @internal
|
|
153
|
-
*/
|
|
154
|
-
dangerouslyGetStep(id: number): ExecutableStep;
|
|
155
75
|
private planOperation;
|
|
156
76
|
/**
|
|
157
77
|
* Plans a GraphQL query operation.
|
|
@@ -170,7 +90,7 @@ export declare class OperationPlan {
|
|
|
170
90
|
* create one item plan per parent plan.
|
|
171
91
|
*/
|
|
172
92
|
private itemStepForListStep;
|
|
173
|
-
processGroupedFieldSet(outputPlan: OutputPlan, path: readonly string[], polymorphicPath: string | null, polymorphicPaths: ReadonlySet<string> | null, parentStep:
|
|
93
|
+
processGroupedFieldSet(outputPlan: OutputPlan, path: readonly string[], polymorphicPath: string | null, polymorphicPaths: ReadonlySet<string> | null, parentStep: Step, objectType: GraphQLObjectType, objectTypeFields: GraphQLFieldMap<any, any>, isMutation: boolean, groupedFieldSet: SelectionSetDigest): void;
|
|
174
94
|
/**
|
|
175
95
|
*
|
|
176
96
|
* @param outputPlan - The output plan that this selection set is being added to
|
|
@@ -181,6 +101,7 @@ export declare class OperationPlan {
|
|
|
181
101
|
* @param isMutation - If true this selection set should be executed serially rather than in parallel (each field gets its own LayerPlan)
|
|
182
102
|
*/
|
|
183
103
|
private planSelectionSet;
|
|
104
|
+
private internalDependency;
|
|
184
105
|
private planIntoOutputPlan;
|
|
185
106
|
private polymorphicLayerPlanByPathByLayerPlan;
|
|
186
107
|
private getPolymorphicLayerPlan;
|
|
@@ -192,7 +113,6 @@ export declare class OperationPlan {
|
|
|
192
113
|
* @see https://spec.graphql.org/draft/#CoerceArgumentValues()
|
|
193
114
|
*/
|
|
194
115
|
private getTrackedArguments;
|
|
195
|
-
withModifiers<T>(cb: () => T): T;
|
|
196
116
|
/**
|
|
197
117
|
* Sets up tracking for the given value (variableValues, context, rootValue).
|
|
198
118
|
*/
|
|
@@ -204,13 +124,6 @@ export declare class OperationPlan {
|
|
|
204
124
|
private validateSteps;
|
|
205
125
|
private replaceStep;
|
|
206
126
|
private processStep;
|
|
207
|
-
/**
|
|
208
|
-
* Process the given steps, either dependencies first (root to leaf) or
|
|
209
|
-
* dependents first (leaves to root).
|
|
210
|
-
*
|
|
211
|
-
* @internal
|
|
212
|
-
*/
|
|
213
|
-
processSteps(actionDescription: string, order: "dependents-first" | "dependencies-first", isReadonly: boolean, callback: (plan: ExecutableStep) => ExecutableStep): void;
|
|
214
127
|
/**
|
|
215
128
|
* Peers are steps of the same type (but not the same step!) that are in
|
|
216
129
|
* compatible layers and have the same dependencies. Peers must not have side
|
|
@@ -246,7 +159,6 @@ export declare class OperationPlan {
|
|
|
246
159
|
private hoistAndDeduplicate;
|
|
247
160
|
private hoistSteps;
|
|
248
161
|
private pushDownSteps;
|
|
249
|
-
private getStepOptionsForStep;
|
|
250
162
|
/**
|
|
251
163
|
* Calls the 'optimize' method on a plan, which may cause the plan to
|
|
252
164
|
* communicate with its (deep) dependencies, and even to replace itself with
|
|
@@ -258,6 +170,7 @@ export declare class OperationPlan {
|
|
|
258
170
|
* know all our dependent's needs before we optimise ourself.
|
|
259
171
|
*/
|
|
260
172
|
private optimizeSteps;
|
|
173
|
+
private inlineSteps;
|
|
261
174
|
/** Finalizes each step */
|
|
262
175
|
private finalizeSteps;
|
|
263
176
|
private finalizeLayerPlans;
|
|
@@ -267,16 +180,29 @@ export declare class OperationPlan {
|
|
|
267
180
|
private finalizeOutputPlans;
|
|
268
181
|
private walkOutputPlans;
|
|
269
182
|
generatePlanJSON(): GrafastPlanJSON;
|
|
270
|
-
finishSubroutine(subroutineStep:
|
|
183
|
+
finishSubroutine(subroutineStep: Step, layerPlan: LayerPlan<LayerPlanReasonSubroutine>): void;
|
|
184
|
+
getStepsByMetaKey(metaKey: string | number | symbol): Step[];
|
|
185
|
+
getStepsByStepClass<TClass extends Step>(klass: {
|
|
186
|
+
new (...args: any[]): TClass;
|
|
187
|
+
}): TClass[];
|
|
188
|
+
private _cacheStepStoreByLayerPlanAndActionKey;
|
|
271
189
|
/**
|
|
272
|
-
*
|
|
190
|
+
* Cache a generated step by a given identifier (cacheKey) such that we don't
|
|
191
|
+
* need to regenerate it on future calls, significantly reducing the load on
|
|
192
|
+
* deduplication later.
|
|
193
|
+
*
|
|
194
|
+
* Note: automatically extends the cached step into other (relevant)
|
|
195
|
+
* polymorphic paths; if this shouldn't be the case then don't use cacheStep
|
|
196
|
+
* and instead rely on deduplication as usual.
|
|
273
197
|
*
|
|
274
|
-
* @
|
|
198
|
+
* @experimental
|
|
275
199
|
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
200
|
+
cacheStep<T extends Step>(ownerStep: Step, actionKey: string, cacheKey: symbol | string | number | boolean | null | undefined, cb: () => T): T;
|
|
201
|
+
/**
|
|
202
|
+
* Clears the cache, typically due to side effects having taken place. Called
|
|
203
|
+
* from setting hasSideEffects on an ExecutableStep, among other places.
|
|
204
|
+
*/
|
|
205
|
+
resetCache(): void;
|
|
206
|
+
withRootLayerPlan<T>(cb: () => T): T;
|
|
281
207
|
}
|
|
282
208
|
//# sourceMappingURL=OperationPlan.d.ts.map
|