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
|
@@ -1,39 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.GraphQLResolveTypeStep = exports.GraphQLResolverStep = void 0;
|
|
4
|
+
exports.graphqlResolveType = graphqlResolveType;
|
|
5
5
|
exports.graphqlResolver = graphqlResolver;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const graphql = tslib_1.__importStar(require("graphql"));
|
|
8
|
-
const iterall_1 = require("iterall");
|
|
9
8
|
const index_js_1 = require("../index.js");
|
|
10
|
-
const polymorphic_js_1 = require("../polymorphic.js");
|
|
11
9
|
const step_js_1 = require("../step.js");
|
|
12
10
|
const utils_js_1 = require("../utils.js");
|
|
13
|
-
const { defaultTypeResolver
|
|
14
|
-
function dcr(data, // but not a promise
|
|
15
|
-
context, resolveInfo) {
|
|
16
|
-
if (data == null) {
|
|
17
|
-
return data;
|
|
18
|
-
}
|
|
19
|
-
else if (data instanceof Error) {
|
|
20
|
-
return (0, index_js_1.flagError)(data);
|
|
21
|
-
}
|
|
22
|
-
else if ((0, utils_js_1.isPromiseLike)(data)) {
|
|
23
|
-
return data.then((data) => dcr(data, context, resolveInfo));
|
|
24
|
-
}
|
|
25
|
-
if ((0, iterall_1.isIterable)(data)) {
|
|
26
|
-
const list = Array.isArray(data) ? data : [...data];
|
|
27
|
-
if (list.some(utils_js_1.isPromiseLike)) {
|
|
28
|
-
const resolved = Promise.all(list.map((entry) => (0, utils_js_1.isPromiseLike)(entry) ? entry.then(null, index_js_1.flagError) : entry));
|
|
29
|
-
// TODO: this does recursion which is inefficient and also incorrect. We
|
|
30
|
-
// should only traverse as deep as the GraphQL type has lists.
|
|
31
|
-
return dcr(resolved, context, resolveInfo);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// TODO: support async iterables
|
|
35
|
-
return { data, context, resolveInfo };
|
|
36
|
-
}
|
|
11
|
+
const { defaultTypeResolver } = graphql;
|
|
37
12
|
/**
|
|
38
13
|
* Calls the given GraphQL resolver for each input - emulates GraphQL
|
|
39
14
|
* resolution.
|
|
@@ -45,19 +20,18 @@ class GraphQLResolverStep extends step_js_1.UnbatchedStep {
|
|
|
45
20
|
moduleName: "grafast",
|
|
46
21
|
exportName: "GraphQLResolverStep",
|
|
47
22
|
}; }
|
|
48
|
-
constructor(resolver, subscriber, $plan, $args, resolveInfoBase
|
|
23
|
+
constructor(resolver, subscriber, $plan, $args, resolveInfoBase) {
|
|
49
24
|
super();
|
|
50
25
|
this.resolver = resolver;
|
|
51
26
|
this.subscriber = subscriber;
|
|
52
27
|
this.resolveInfoBase = resolveInfoBase;
|
|
53
|
-
this.returnContextAndResolveInfo = returnContextAndResolveInfo;
|
|
54
28
|
this.isSyncAndSafe = false;
|
|
55
29
|
this.allowMultipleOptimizations = false;
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
30
|
+
this.addDependency($plan);
|
|
31
|
+
this.addDependency($args);
|
|
32
|
+
this.addDependency((0, index_js_1.context)());
|
|
33
|
+
this.addDependency(this.operationPlan.variableValuesStep);
|
|
34
|
+
this.addDependency(this.operationPlan.rootValueStep);
|
|
61
35
|
this.isNotRoot = ![
|
|
62
36
|
this.operationPlan.queryType,
|
|
63
37
|
this.operationPlan.mutationType,
|
|
@@ -65,11 +39,12 @@ class GraphQLResolverStep extends step_js_1.UnbatchedStep {
|
|
|
65
39
|
].includes(resolveInfoBase.parentType);
|
|
66
40
|
}
|
|
67
41
|
toStringMeta() {
|
|
68
|
-
|
|
42
|
+
const resolverName = this.resolver?.displayName ||
|
|
69
43
|
this.resolver?.name ||
|
|
70
44
|
this.subscriber?.displayName ||
|
|
71
45
|
this.subscriber?.name ||
|
|
72
|
-
null
|
|
46
|
+
null;
|
|
47
|
+
return `${this.resolveInfoBase.parentType.name}.${this.resolveInfoBase.fieldName}${resolverName && resolverName !== "resolve" ? `:${resolverName}` : ""}`;
|
|
73
48
|
}
|
|
74
49
|
unbatchedExecute(extra, source, args, context, variableValues, rootValue) {
|
|
75
50
|
if (!extra.stream) {
|
|
@@ -87,12 +62,7 @@ class GraphQLResolverStep extends step_js_1.UnbatchedStep {
|
|
|
87
62
|
},
|
|
88
63
|
});
|
|
89
64
|
const data = this.resolver?.(source, args, context, resolveInfo);
|
|
90
|
-
|
|
91
|
-
return dcr(data, context, resolveInfo);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
return flagErrorIfErrorAsync(data);
|
|
95
|
-
}
|
|
65
|
+
return flagErrorIfErrorAsync(data);
|
|
96
66
|
}
|
|
97
67
|
else {
|
|
98
68
|
if (this.isNotRoot) {
|
|
@@ -101,9 +71,6 @@ class GraphQLResolverStep extends step_js_1.UnbatchedStep {
|
|
|
101
71
|
if (this.subscriber == null) {
|
|
102
72
|
return Promise.reject(new Error(`Cannot subscribe to field`));
|
|
103
73
|
}
|
|
104
|
-
if (this.returnContextAndResolveInfo) {
|
|
105
|
-
return Promise.reject(new Error(`Subscription with returnContextAndResolveInfo is not supported`));
|
|
106
|
-
}
|
|
107
74
|
const resolveInfo = Object.assign(Object.create(this.resolveInfoBase), {
|
|
108
75
|
// ENHANCE: add support for path
|
|
109
76
|
variableValues,
|
|
@@ -118,40 +85,36 @@ class GraphQLResolverStep extends step_js_1.UnbatchedStep {
|
|
|
118
85
|
}
|
|
119
86
|
exports.GraphQLResolverStep = GraphQLResolverStep;
|
|
120
87
|
/** @internal */
|
|
121
|
-
class
|
|
88
|
+
class GraphQLResolveTypeStep extends step_js_1.Step {
|
|
122
89
|
static { this.$$export = {
|
|
123
90
|
moduleName: "grafast",
|
|
124
|
-
exportName: "
|
|
91
|
+
exportName: "GraphQLResolveTypeStep",
|
|
125
92
|
}; }
|
|
126
|
-
constructor($
|
|
93
|
+
constructor($stepOrSpecifier, info) {
|
|
127
94
|
super();
|
|
128
|
-
|
|
95
|
+
// Could be promises
|
|
129
96
|
this.isSyncAndSafe = false;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (!this.nullableInnerType) {
|
|
152
|
-
throw new Error(`GrafastInternalError<83f3533a-db8e-4eb9-9251-2a165ae6147b>: did not expect ${this}.listItem() to be called since it wasn't handling a list type`);
|
|
153
|
-
}
|
|
154
|
-
return graphqlItemHandler($item, this.nullableInnerType);
|
|
97
|
+
const { abstractType } = info;
|
|
98
|
+
this.abstractType = abstractType;
|
|
99
|
+
this.resolveInfoBase = {
|
|
100
|
+
...this.operationPlan.resolveInfoOperationBase,
|
|
101
|
+
// TODO: this resolveInfo is seriously hacked, we don't know a number of
|
|
102
|
+
// things that _shouldn't_ be necessary for figuring out the type, so
|
|
103
|
+
// we'll run in this crippled state.
|
|
104
|
+
// Really we should inherit the resolveInfo from the field itself, but
|
|
105
|
+
// currently that doesn't get passed through. Maybe it should have its
|
|
106
|
+
// own step which we pass through as a dependency?
|
|
107
|
+
fieldName: null,
|
|
108
|
+
parentType: null,
|
|
109
|
+
path: null,
|
|
110
|
+
fieldNodes: null,
|
|
111
|
+
// Even this is a lie
|
|
112
|
+
returnType: abstractType,
|
|
113
|
+
};
|
|
114
|
+
this.addDataDependency($stepOrSpecifier);
|
|
115
|
+
this.addUnaryDependency((0, index_js_1.context)());
|
|
116
|
+
this.addUnaryDependency(this.operationPlan.variableValuesStep);
|
|
117
|
+
this.addUnaryDependency(this.operationPlan.rootValueStep);
|
|
155
118
|
}
|
|
156
119
|
/**
|
|
157
120
|
* Akin to graphql-js' completeAbstractValue... but just the typeName
|
|
@@ -159,9 +122,6 @@ class GraphQLItemHandler extends step_js_1.Step {
|
|
|
159
122
|
*/
|
|
160
123
|
figureOutTheTypeOf(data, context, resolveInfo) {
|
|
161
124
|
const abstractType = this.abstractType;
|
|
162
|
-
if (!abstractType) {
|
|
163
|
-
throw new Error("GrafastInternalError<5ea0892a-e9f6-479c-9b0b-2b09e46eecb6>: No abstract type? How can this be?");
|
|
164
|
-
}
|
|
165
125
|
if (abstractType.resolveType != null) {
|
|
166
126
|
return abstractType.resolveType(data, context, resolveInfo, abstractType);
|
|
167
127
|
}
|
|
@@ -169,77 +129,32 @@ class GraphQLItemHandler extends step_js_1.Step {
|
|
|
169
129
|
return defaultTypeResolver(data, context, resolveInfo, abstractType);
|
|
170
130
|
}
|
|
171
131
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
wrapListData(data, context, resolveInfo) {
|
|
194
|
-
if (data == null) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
if (!Array.isArray(data)) {
|
|
198
|
-
console.warn(`${this}: data wasn't an array, so we're returning null`);
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
return data.map((data) => dcr(data, context, resolveInfo));
|
|
202
|
-
}
|
|
203
|
-
execute({ indexMap, values: [values0], }) {
|
|
204
|
-
if (this.abstractType !== undefined) {
|
|
205
|
-
return indexMap((i) => {
|
|
206
|
-
const data = values0.at(i);
|
|
207
|
-
if (data == null) {
|
|
208
|
-
return data;
|
|
209
|
-
}
|
|
210
|
-
else if ((0, utils_js_1.isPromiseLike)(data.data)) {
|
|
211
|
-
return data.data.then((resolvedData) => this.polymorphicWrapData(resolvedData, data.context, data.resolveInfo));
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
return this.polymorphicWrapData(data.data, data.context, data.resolveInfo);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
else if (this.nullableInnerType != null) {
|
|
219
|
-
return indexMap((i) => {
|
|
220
|
-
const d = values0.at(i);
|
|
221
|
-
if (d == null) {
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
const { data, context, resolveInfo } = d;
|
|
226
|
-
if ((0, utils_js_1.isPromiseLike)(data)) {
|
|
227
|
-
return data.then((data) => this.wrapListData(data, context, resolveInfo));
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
return this.wrapListData(data, context, resolveInfo);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
throw new Error(`GrafastInternalError<6a3ed701-6b53-41e6-9a64-fbea57c76ae7>: has to be abstract or list`);
|
|
237
|
-
}
|
|
132
|
+
execute({ indexMap, values: [values0, contextVal, variableValuesVal, rootValueVal], }) {
|
|
133
|
+
const context = contextVal.unaryValue();
|
|
134
|
+
const variableValues = variableValuesVal.unaryValue();
|
|
135
|
+
const rootValue = rootValueVal.unaryValue();
|
|
136
|
+
const resolveInfo = {
|
|
137
|
+
...this.resolveInfoBase,
|
|
138
|
+
rootValue,
|
|
139
|
+
variableValues,
|
|
140
|
+
};
|
|
141
|
+
return indexMap((i) => {
|
|
142
|
+
const data = values0.at(i);
|
|
143
|
+
if (data == null) {
|
|
144
|
+
return data;
|
|
145
|
+
}
|
|
146
|
+
else if ((0, utils_js_1.isPromiseLike)(data)) {
|
|
147
|
+
return data.then((resolvedData) => this.figureOutTheTypeOf(resolvedData, context, resolveInfo));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return this.figureOutTheTypeOf(data, context, resolveInfo);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
238
153
|
}
|
|
239
154
|
}
|
|
240
|
-
exports.
|
|
241
|
-
function
|
|
242
|
-
return new
|
|
155
|
+
exports.GraphQLResolveTypeStep = GraphQLResolveTypeStep;
|
|
156
|
+
function graphqlResolveType($stepOrSpecifier, info) {
|
|
157
|
+
return new GraphQLResolveTypeStep($stepOrSpecifier, info);
|
|
243
158
|
}
|
|
244
159
|
/**
|
|
245
160
|
* Emulates what GraphQL does when calling a resolver, including handling of
|
|
@@ -248,20 +163,7 @@ function graphqlItemHandler($item, nullableType) {
|
|
|
248
163
|
* @internal
|
|
249
164
|
*/
|
|
250
165
|
function graphqlResolver(resolver, subscriber, $step, $args, resolveInfoBase) {
|
|
251
|
-
|
|
252
|
-
const namedType = getNamedType(returnType);
|
|
253
|
-
const isAbstract = isAbstractType(namedType);
|
|
254
|
-
const $resolverResult = new GraphQLResolverStep(resolver, subscriber, $step, $args, resolveInfoBase, isAbstract);
|
|
255
|
-
if (isAbstract) {
|
|
256
|
-
if (subscriber != null) {
|
|
257
|
-
throw new index_js_1.SafeError(`GraphQL subscribe function emulation currently doesn't support polymorphism`);
|
|
258
|
-
}
|
|
259
|
-
const nullableType = getNullableType(returnType);
|
|
260
|
-
return graphqlItemHandler($resolverResult, nullableType);
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
return $resolverResult;
|
|
264
|
-
}
|
|
166
|
+
return new GraphQLResolverStep(resolver, subscriber, $step, $args, resolveInfoBase);
|
|
265
167
|
}
|
|
266
168
|
function flagErrorIfError(data) {
|
|
267
169
|
return data instanceof Error ? (0, index_js_1.flagError)(data) : data;
|
package/dist/steps/index.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import type { __TrackedValueStep, OperationPlan } from "../index.js";
|
|
2
|
-
import type { __ValueStep } from "./__value.js";
|
|
3
|
-
export declare function operationPlan(): OperationPlan;
|
|
4
|
-
export declare function context<TContext extends Grafast.Context = Grafast.Context>(): __ValueStep<TContext>;
|
|
5
|
-
export declare function rootValue(): __ValueStep<Record<string, any>>;
|
|
6
|
-
export declare function trackedContext<TContext extends Grafast.Context = Grafast.Context>(): __TrackedValueStep<TContext>;
|
|
7
|
-
export declare function trackedRootValue(): __TrackedValueStep<Record<string, any>>;
|
|
8
|
-
/**
|
|
9
|
-
* Turns on debug mode, calls the callback, and then turns debug mode back off
|
|
10
|
-
* again.
|
|
11
|
-
*/
|
|
12
|
-
export declare function debugPlans<T>(callback: () => T): T;
|
|
13
1
|
export { __FlagStep, assertNotNull, inhibitOnNull, trap, TRAP_ERROR, TRAP_ERROR_OR_INHIBITED, TRAP_INHIBITED, } from "./__flag.js";
|
|
14
|
-
export { access, AccessStep } from "./access.js";
|
|
2
|
+
export { access, AccessStep, get } from "./access.js";
|
|
3
|
+
export { coalesce, CoalesceStep } from "./coalesce.js";
|
|
15
4
|
export { assertEdgeCapableStep, assertPageInfoCapableStep, connection, ConnectionCapableStep, ConnectionStep, EdgeCapableStep, EdgeStep, PageInfoCapableStep, } from "./connection.js";
|
|
16
5
|
export { constant, ConstantStep } from "./constant.js";
|
|
17
6
|
export { each } from "./each.js";
|
|
@@ -41,8 +30,7 @@ export { applyInput, ApplyInputStep, assertModifier, isModifier, Modifier, } fro
|
|
|
41
30
|
export { applyTransforms, ApplyTransformsStep } from "./applyTransforms.js";
|
|
42
31
|
export { bakedInput, bakedInputRuntime, BakedInputStep } from "./bakedInput.js";
|
|
43
32
|
export { condition, ConditionStep } from "./condition.js";
|
|
44
|
-
export {
|
|
33
|
+
export { graphqlResolver, GraphQLResolverStep } from "./graphqlResolver.js";
|
|
45
34
|
export { LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, loadOne, LoadOneCallback, loadOneCallback, LoadOptions, LoadStep, } from "./load.js";
|
|
46
|
-
export { polymorphicBranch, PolymorphicBranchMatcher, PolymorphicBranchMatchers, PolymorphicBranchStep, } from "./polymorphicBranch.js";
|
|
47
35
|
export { proxy, ProxyStep } from "./proxy.js";
|
|
48
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/steps/index.js
CHANGED
|
@@ -1,41 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.ProxyStep = exports.proxy = exports.
|
|
5
|
-
exports.operationPlan = operationPlan;
|
|
6
|
-
exports.context = context;
|
|
7
|
-
exports.rootValue = rootValue;
|
|
8
|
-
exports.trackedContext = trackedContext;
|
|
9
|
-
exports.trackedRootValue = trackedRootValue;
|
|
10
|
-
exports.debugPlans = debugPlans;
|
|
11
|
-
const withGlobalLayerPlan_js_1 = require("../engine/lib/withGlobalLayerPlan.js");
|
|
12
|
-
const global_js_1 = require("../global.js");
|
|
13
|
-
function operationPlan() {
|
|
14
|
-
return (0, withGlobalLayerPlan_js_1.currentLayerPlan)().operationPlan;
|
|
15
|
-
}
|
|
16
|
-
function context() {
|
|
17
|
-
return operationPlan().contextStep;
|
|
18
|
-
}
|
|
19
|
-
function rootValue() {
|
|
20
|
-
return operationPlan().rootValueStep;
|
|
21
|
-
}
|
|
22
|
-
function trackedContext() {
|
|
23
|
-
return operationPlan().trackedContextStep;
|
|
24
|
-
}
|
|
25
|
-
function trackedRootValue() {
|
|
26
|
-
return operationPlan().trackedRootValueStep;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Turns on debug mode, calls the callback, and then turns debug mode back off
|
|
30
|
-
* again.
|
|
31
|
-
*/
|
|
32
|
-
function debugPlans(callback) {
|
|
33
|
-
const oldDebug = (0, global_js_1.getDebug)();
|
|
34
|
-
(0, global_js_1.setDebug)(true);
|
|
35
|
-
const result = callback();
|
|
36
|
-
(0, global_js_1.setDebug)(oldDebug);
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
3
|
+
exports.ReverseStep = exports.reverseArray = exports.reverse = exports.RemapKeysStep = exports.remapKeys = exports.partitionByIndex = exports.ObjectStep = exports.object = exports.specFromNodeId = exports.NodeStep = exports.nodeIdFromNode = exports.node = exports.makeDecodeNodeIdRuntime = exports.makeDecodeNodeId = exports.listTransform = exports.__ListTransformStep = exports.ListenStep = exports.listen = exports.ListStep = exports.list = exports.LastStep = exports.last = exports.LambdaStep = exports.lambda = exports.groupBy = exports.FirstStep = exports.first = exports.filter = exports.ErrorStep = exports.error = exports.each = exports.ConstantStep = exports.constant = exports.EdgeStep = exports.ConnectionStep = exports.connection = exports.assertPageInfoCapableStep = exports.assertEdgeCapableStep = exports.CoalesceStep = exports.coalesce = exports.get = exports.AccessStep = exports.access = exports.TRAP_INHIBITED = exports.TRAP_ERROR_OR_INHIBITED = exports.TRAP_ERROR = exports.trap = exports.inhibitOnNull = exports.assertNotNull = exports.__FlagStep = void 0;
|
|
4
|
+
exports.ProxyStep = exports.proxy = exports.LoadStep = exports.loadOneCallback = exports.loadOne = exports.loadManyCallback = exports.loadMany = exports.LoadedRecordStep = exports.GraphQLResolverStep = exports.graphqlResolver = exports.ConditionStep = exports.condition = exports.BakedInputStep = exports.bakedInputRuntime = exports.bakedInput = exports.ApplyTransformsStep = exports.applyTransforms = exports.Modifier = exports.isModifier = exports.assertModifier = exports.ApplyInputStep = exports.applyInput = exports.__ValueStep = exports.__TrackedValueStep = exports.__ItemStep = exports.__InputStaticLeafStep = exports.__InputObjectStep = exports.__InputListStep = exports.SideEffectStep = exports.sideEffect = exports.setter = exports.Setter = exports.createObjectAndApplyChildren = void 0;
|
|
39
5
|
var __flag_js_1 = require("./__flag.js");
|
|
40
6
|
Object.defineProperty(exports, "__FlagStep", { enumerable: true, get: function () { return __flag_js_1.__FlagStep; } });
|
|
41
7
|
Object.defineProperty(exports, "assertNotNull", { enumerable: true, get: function () { return __flag_js_1.assertNotNull; } });
|
|
@@ -47,6 +13,10 @@ Object.defineProperty(exports, "TRAP_INHIBITED", { enumerable: true, get: functi
|
|
|
47
13
|
var access_js_1 = require("./access.js");
|
|
48
14
|
Object.defineProperty(exports, "access", { enumerable: true, get: function () { return access_js_1.access; } });
|
|
49
15
|
Object.defineProperty(exports, "AccessStep", { enumerable: true, get: function () { return access_js_1.AccessStep; } });
|
|
16
|
+
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return access_js_1.get; } });
|
|
17
|
+
var coalesce_js_1 = require("./coalesce.js");
|
|
18
|
+
Object.defineProperty(exports, "coalesce", { enumerable: true, get: function () { return coalesce_js_1.coalesce; } });
|
|
19
|
+
Object.defineProperty(exports, "CoalesceStep", { enumerable: true, get: function () { return coalesce_js_1.CoalesceStep; } });
|
|
50
20
|
var connection_js_1 = require("./connection.js");
|
|
51
21
|
Object.defineProperty(exports, "assertEdgeCapableStep", { enumerable: true, get: function () { return connection_js_1.assertEdgeCapableStep; } });
|
|
52
22
|
Object.defineProperty(exports, "assertPageInfoCapableStep", { enumerable: true, get: function () { return connection_js_1.assertPageInfoCapableStep; } });
|
|
@@ -139,8 +109,6 @@ var condition_js_1 = require("./condition.js");
|
|
|
139
109
|
Object.defineProperty(exports, "condition", { enumerable: true, get: function () { return condition_js_1.condition; } });
|
|
140
110
|
Object.defineProperty(exports, "ConditionStep", { enumerable: true, get: function () { return condition_js_1.ConditionStep; } });
|
|
141
111
|
var graphqlResolver_js_1 = require("./graphqlResolver.js");
|
|
142
|
-
Object.defineProperty(exports, "GraphQLItemHandler", { enumerable: true, get: function () { return graphqlResolver_js_1.GraphQLItemHandler; } });
|
|
143
|
-
Object.defineProperty(exports, "graphqlItemHandler", { enumerable: true, get: function () { return graphqlResolver_js_1.graphqlItemHandler; } });
|
|
144
112
|
Object.defineProperty(exports, "graphqlResolver", { enumerable: true, get: function () { return graphqlResolver_js_1.graphqlResolver; } });
|
|
145
113
|
Object.defineProperty(exports, "GraphQLResolverStep", { enumerable: true, get: function () { return graphqlResolver_js_1.GraphQLResolverStep; } });
|
|
146
114
|
var load_js_1 = require("./load.js");
|
|
@@ -150,9 +118,6 @@ Object.defineProperty(exports, "loadManyCallback", { enumerable: true, get: func
|
|
|
150
118
|
Object.defineProperty(exports, "loadOne", { enumerable: true, get: function () { return load_js_1.loadOne; } });
|
|
151
119
|
Object.defineProperty(exports, "loadOneCallback", { enumerable: true, get: function () { return load_js_1.loadOneCallback; } });
|
|
152
120
|
Object.defineProperty(exports, "LoadStep", { enumerable: true, get: function () { return load_js_1.LoadStep; } });
|
|
153
|
-
var polymorphicBranch_js_1 = require("./polymorphicBranch.js");
|
|
154
|
-
Object.defineProperty(exports, "polymorphicBranch", { enumerable: true, get: function () { return polymorphicBranch_js_1.polymorphicBranch; } });
|
|
155
|
-
Object.defineProperty(exports, "PolymorphicBranchStep", { enumerable: true, get: function () { return polymorphicBranch_js_1.PolymorphicBranchStep; } });
|
|
156
121
|
var proxy_js_1 = require("./proxy.js");
|
|
157
122
|
Object.defineProperty(exports, "proxy", { enumerable: true, get: function () { return proxy_js_1.proxy; } });
|
|
158
123
|
Object.defineProperty(exports, "ProxyStep", { enumerable: true, get: function () { return proxy_js_1.ProxyStep; } });
|
package/dist/steps/lambda.js
CHANGED
|
@@ -19,7 +19,7 @@ class LambdaStep extends step_js_1.UnbatchedStep {
|
|
|
19
19
|
// Lambda is only sync and safe if the callback is; so default to false
|
|
20
20
|
this.isSyncAndSafe = false;
|
|
21
21
|
this.allowMultipleOptimizations = true;
|
|
22
|
-
this.depId = $plan != null ? this.
|
|
22
|
+
this.depId = $plan != null ? this.addDataDependency($plan) : null;
|
|
23
23
|
if (fn.hasSideEffects) {
|
|
24
24
|
this.hasSideEffects = true;
|
|
25
25
|
}
|
package/dist/steps/last.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { $$deepDepSkip } from "../constants.js";
|
|
1
2
|
import type { 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 LastStep<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
|
unbatchedExecute: (_extra: UnbatchedExecutionExtra, list: ReadonlyArray<TData>) => TData;
|
|
14
16
|
deduplicate(peers: LastStep<TData>[]): LastStep<TData>[];
|
|
15
17
|
optimize(): any;
|
package/dist/steps/last.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LastStep = void 0;
|
|
4
4
|
exports.last = last;
|
|
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");
|
|
@@ -19,6 +20,9 @@ class LastStep extends step_js_1.UnbatchedStep {
|
|
|
19
20
|
};
|
|
20
21
|
this.addDependency((0, connection_js_1.itemsOrStep)(parentPlan));
|
|
21
22
|
}
|
|
23
|
+
[constants_js_1.$$deepDepSkip]() {
|
|
24
|
+
return this.getDepOptions(0).step;
|
|
25
|
+
}
|
|
22
26
|
deduplicate(peers) {
|
|
23
27
|
return peers;
|
|
24
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { $$deepDepSkip } from "../constants.js";
|
|
1
2
|
import type { ConnectionCapableStep, ExecutionDetails } from "../index.js";
|
|
2
3
|
import type { GrafastResultsList } from "../interfaces.js";
|
|
3
|
-
import { $$deepDepSkip } from "../interfaces.js";
|
|
4
4
|
import type { ListCapableStep } from "../step.js";
|
|
5
5
|
import { Step } from "../step.js";
|
|
6
6
|
import { __ItemStep } from "./__item.js";
|
|
@@ -34,7 +34,7 @@ export declare class __ListTransformStep<TListStep extends Step<readonly any[]>
|
|
|
34
34
|
};
|
|
35
35
|
isSyncAndSafe: boolean;
|
|
36
36
|
private listStepDepId;
|
|
37
|
-
private
|
|
37
|
+
private rawListStepRefId;
|
|
38
38
|
itemPlanCallback: ListTransformItemPlanCallback<ItemsStep<TListStep>, TDepsStep>;
|
|
39
39
|
initialState: () => TMemo;
|
|
40
40
|
reduceCallback: ListTransformReduce<TMemo, TDepsStep extends Step<infer U> ? U : never>;
|
|
@@ -4,11 +4,11 @@ exports.__ListTransformStep = void 0;
|
|
|
4
4
|
exports.listTransform = listTransform;
|
|
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
|
-
const interfaces_js_1 = require("../interfaces.js");
|
|
12
12
|
const step_js_1 = require("../step.js");
|
|
13
13
|
const __item_js_1 = require("./__item.js");
|
|
14
14
|
const connection_js_1 = require("./connection.js");
|
|
@@ -33,11 +33,7 @@ class __ListTransformStep extends step_js_1.Step {
|
|
|
33
33
|
const { listStep: rawListStep, itemPlanCallback, initialState, reduceCallback, finalizeCallback, listItem, meta, optimize, connectionClone, } = options;
|
|
34
34
|
const listStep = (0, connection_js_1.itemsOrStep)(rawListStep);
|
|
35
35
|
this.listStepDepId = this.addDependency(listStep);
|
|
36
|
-
|
|
37
|
-
this.rawListStepDepId =
|
|
38
|
-
rawListStep === listStep
|
|
39
|
-
? this.listStepDepId
|
|
40
|
-
: this.addDependency(rawListStep);
|
|
36
|
+
this.rawListStepRefId = this.addRef(rawListStep);
|
|
41
37
|
this.itemPlanCallback = itemPlanCallback;
|
|
42
38
|
this.initialState = initialState;
|
|
43
39
|
this.reduceCallback = reduceCallback;
|
|
@@ -49,11 +45,12 @@ class __ListTransformStep extends step_js_1.Step {
|
|
|
49
45
|
}
|
|
50
46
|
this.connectionClone = connectionClone;
|
|
51
47
|
// Plan this subroutine
|
|
52
|
-
this.subroutineLayer = new LayerPlan_js_1.LayerPlan(this.operationPlan,
|
|
48
|
+
this.subroutineLayer = new LayerPlan_js_1.LayerPlan(this.operationPlan, {
|
|
53
49
|
type: "subroutine",
|
|
50
|
+
parentLayerPlan: this.layerPlan,
|
|
54
51
|
parentStep: this,
|
|
55
52
|
});
|
|
56
|
-
const itemPlan = (0, withGlobalLayerPlan_js_1.withGlobalLayerPlan)(this.subroutineLayer, listStep.polymorphicPaths, () => {
|
|
53
|
+
const itemPlan = (0, withGlobalLayerPlan_js_1.withGlobalLayerPlan)(this.subroutineLayer, listStep.polymorphicPaths, null, () => {
|
|
57
54
|
// This does NOT use `itemPlanFor` because __ListTransformPlans are special.
|
|
58
55
|
const $__listItem = new __item_js_1.__ItemStep(listStep);
|
|
59
56
|
$__listItem.transformStepId = this.id;
|
|
@@ -77,13 +74,13 @@ class __ListTransformStep extends step_js_1.Step {
|
|
|
77
74
|
return this.meta;
|
|
78
75
|
}
|
|
79
76
|
getListStep() {
|
|
80
|
-
return this.
|
|
77
|
+
return this.getRef(this.rawListStepRefId);
|
|
81
78
|
}
|
|
82
|
-
[
|
|
79
|
+
[constants_js_1.$$deepDepSkip]() {
|
|
83
80
|
return this.getListStep();
|
|
84
81
|
}
|
|
85
82
|
dangerouslyGetListPlan() {
|
|
86
|
-
return this.
|
|
83
|
+
return this.getRef(this.rawListStepRefId);
|
|
87
84
|
}
|
|
88
85
|
deduplicate(peers) {
|
|
89
86
|
return peers.filter((peer) => peer.itemPlanCallback === this.itemPlanCallback &&
|
|
@@ -166,14 +163,15 @@ class __ListTransformStep extends step_js_1.Step {
|
|
|
166
163
|
}
|
|
167
164
|
});
|
|
168
165
|
if (size > 0) {
|
|
169
|
-
const childBucket = (0, executeBucket_js_1.newBucket)({
|
|
166
|
+
const childBucket = (0, executeBucket_js_1.newBucket)(bucket, {
|
|
170
167
|
layerPlan: childLayerPlan,
|
|
171
168
|
size,
|
|
172
169
|
store,
|
|
173
170
|
flagUnion: bucket.flagUnion,
|
|
174
171
|
polymorphicPathList,
|
|
172
|
+
polymorphicType: null,
|
|
175
173
|
iterators,
|
|
176
|
-
}
|
|
174
|
+
});
|
|
177
175
|
await (0, executeBucket_js_1.executeBucket)(childBucket, extra._requestContext);
|
|
178
176
|
}
|
|
179
177
|
const depResults = store.get(rootStep.id);
|