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
package/dist/execute.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.withGrafastArgs = withGrafastArgs;
|
|
4
|
+
exports.execute = execute;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const eventemitter3_1 = tslib_1.__importDefault(require("eventemitter3"));
|
|
6
|
-
const
|
|
7
|
+
const dev_js_1 = require("./dev.js");
|
|
7
8
|
const inspect_js_1 = require("./inspect.js");
|
|
8
9
|
const interfaces_js_1 = require("./interfaces.js");
|
|
10
|
+
const middleware_js_1 = require("./middleware.js");
|
|
9
11
|
const prepare_js_1 = require("./prepare.js");
|
|
10
12
|
const utils_js_1 = require("./utils.js");
|
|
11
|
-
const isDev = typeof process !== "undefined" && process.env.NODE_ENV === "development";
|
|
12
13
|
/**
|
|
13
14
|
* Used by `execute` and `subscribe`.
|
|
14
15
|
* @internal
|
|
15
16
|
*/
|
|
16
|
-
function withGrafastArgs(args
|
|
17
|
-
const options = resolvedPreset?.grafast;
|
|
18
|
-
if (isDev) {
|
|
17
|
+
function withGrafastArgs(args) {
|
|
18
|
+
const options = args.resolvedPreset?.grafast;
|
|
19
|
+
if (dev_js_1.isDev) {
|
|
19
20
|
if (args.rootValue != null &&
|
|
20
21
|
(typeof args.rootValue !== "object" ||
|
|
21
22
|
Object.keys(args.rootValue).length > 0)) {
|
|
@@ -54,8 +55,9 @@ function withGrafastArgs(args, resolvedPreset, outputDataAsString) {
|
|
|
54
55
|
}
|
|
55
56
|
const rootValue = (0, prepare_js_1.grafastPrepare)(args, {
|
|
56
57
|
explain: options?.explain,
|
|
57
|
-
outputDataAsString,
|
|
58
58
|
timeouts: options?.timeouts,
|
|
59
|
+
// TODO: Delete this
|
|
60
|
+
outputDataAsString: args.outputDataAsString,
|
|
59
61
|
});
|
|
60
62
|
if (unlisten !== null) {
|
|
61
63
|
Promise.resolve(rootValue).then(unlisten, unlisten);
|
|
@@ -68,13 +70,27 @@ function withGrafastArgs(args, resolvedPreset, outputDataAsString) {
|
|
|
68
70
|
return rootValue;
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
function execute(args, legacyResolvedPreset, legacyOutputDataAsString) {
|
|
74
|
+
// TODO: remove legacy compatibility
|
|
75
|
+
if (legacyResolvedPreset !== undefined) {
|
|
76
|
+
args.resolvedPreset = legacyResolvedPreset;
|
|
77
|
+
}
|
|
78
|
+
if (legacyOutputDataAsString !== undefined) {
|
|
79
|
+
args.outputDataAsString = legacyOutputDataAsString;
|
|
80
|
+
}
|
|
81
|
+
const { resolvedPreset } = args;
|
|
82
|
+
const middleware = args.middleware === undefined && resolvedPreset != null
|
|
83
|
+
? (0, middleware_js_1.getGrafastMiddleware)(resolvedPreset)
|
|
84
|
+
: (args.middleware ?? null);
|
|
85
|
+
if (args.middleware === undefined) {
|
|
86
|
+
args.middleware = middleware;
|
|
87
|
+
}
|
|
88
|
+
if (middleware !== null) {
|
|
89
|
+
return middleware.run("execute", { args }, executeMiddlewareCallback);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return withGrafastArgs(args);
|
|
93
|
+
}
|
|
78
94
|
}
|
|
79
|
-
|
|
95
|
+
const executeMiddlewareCallback = (event) => withGrafastArgs(event.args);
|
|
80
96
|
//# sourceMappingURL=execute.js.map
|
package/dist/exportAs.d.ts
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Marks that `thing` is exported from the `grafast` module as
|
|
3
|
-
* `exportName` so that `graphile-export` can convert references to `thing`
|
|
4
|
-
* into an `import` statement.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare function exportAs<T extends object>(moduleName: string, thing: T, exportName: string | string[]): T;
|
|
9
|
-
/**
|
|
10
|
-
* Marks that each value in `all` is exported from the `grafast`
|
|
11
|
-
* module as the key in the `all` object so that `graphile-export` can
|
|
12
|
-
* convert references to these values into `import` statements.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare function exportAsMany(moduleName: string, all: {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
}): void;
|
|
1
|
+
export {};
|
|
19
2
|
//# sourceMappingURL=exportAs.d.ts.map
|
package/dist/exportAs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.exportAs = exportAs;
|
|
4
|
+
exports.exportAsMany = exportAsMany;
|
|
4
5
|
const utils_js_1 = require("./utils.js");
|
|
5
6
|
/**
|
|
6
7
|
* Marks that `thing` is exported from the `grafast` module as
|
|
@@ -36,7 +37,6 @@ function exportAs(moduleName, thing, exportName) {
|
|
|
36
37
|
}
|
|
37
38
|
return thing;
|
|
38
39
|
}
|
|
39
|
-
exports.exportAs = exportAs;
|
|
40
40
|
/**
|
|
41
41
|
* Marks that each value in `all` is exported from the `grafast`
|
|
42
42
|
* module as the key in the `all` object so that `graphile-export` can
|
|
@@ -53,5 +53,4 @@ function exportAsMany(moduleName, all) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
exports.exportAsMany = exportAsMany;
|
|
57
56
|
//# sourceMappingURL=exportAs.js.map
|
package/dist/global.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.setDebug = setDebug;
|
|
4
|
+
exports.getDebug = getDebug;
|
|
4
5
|
let debug = false;
|
|
5
6
|
function setDebug(newDebug) {
|
|
6
7
|
debug = newDebug;
|
|
7
8
|
}
|
|
8
|
-
exports.setDebug = setDebug;
|
|
9
9
|
function getDebug() {
|
|
10
10
|
return debug;
|
|
11
11
|
}
|
|
12
|
-
exports.getDebug = getDebug;
|
|
13
12
|
//# sourceMappingURL=global.js.map
|
package/dist/grafastGraphql.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ import type { GrafastArgs } from "./interfaces.js";
|
|
|
5
5
|
* A replacement for GraphQL.js' `graphql` method that calls Grafast's
|
|
6
6
|
* execute instead
|
|
7
7
|
*/
|
|
8
|
-
export declare function grafast(args: GrafastArgs
|
|
8
|
+
export declare function grafast(args: GrafastArgs): PromiseOrValue<ExecutionResult | AsyncGenerator<AsyncExecutionResult, void, undefined>>;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Second and third parameters should be passed as part of args,
|
|
11
|
+
* specifically `resolvedPreset` and `requestContext`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function grafast(args: GrafastArgs, legacyResolvedPreset?: GraphileConfig.ResolvedPreset | undefined, legacyCtx?: Partial<Grafast.RequestContext> | undefined): PromiseOrValue<ExecutionResult | AsyncGenerator<AsyncExecutionResult, void, undefined>>;
|
|
9
14
|
export declare function grafastSync(args: GrafastArgs, legacyResolvedPreset?: GraphileConfig.ResolvedPreset, legacyRequestContext?: Partial<Grafast.RequestContext>): ExecutionResult;
|
|
10
15
|
//# sourceMappingURL=grafastGraphql.d.ts.map
|
package/dist/grafastGraphql.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.grafast = grafast;
|
|
4
|
+
exports.grafastSync = grafastSync;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const lru_1 = tslib_1.__importDefault(require("@graphile/lru"));
|
|
6
7
|
const graphql = tslib_1.__importStar(require("graphql"));
|
|
@@ -8,6 +9,7 @@ const error_js_1 = require("./error.js");
|
|
|
8
9
|
const execute_js_1 = require("./execute.js");
|
|
9
10
|
const index_js_1 = require("./index.js");
|
|
10
11
|
const interfaces_js_1 = require("./interfaces.js");
|
|
12
|
+
const middleware_js_1 = require("./middleware.js");
|
|
11
13
|
const utils_js_1 = require("./utils.js");
|
|
12
14
|
const { GraphQLError, parse, Source, validate, validateSchema } = graphql;
|
|
13
15
|
/** Rough average size per query */
|
|
@@ -79,19 +81,31 @@ const parseAndValidate = (gqlSchema, stringOrSource) => {
|
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
};
|
|
82
|
-
/**
|
|
83
|
-
* A replacement for GraphQL.js' `graphql` method that calls Grafast's
|
|
84
|
-
* execute instead
|
|
85
|
-
*/
|
|
86
84
|
function grafast(args, legacyResolvedPreset, legacyCtx) {
|
|
87
|
-
|
|
85
|
+
// Convert legacy args to properties on `args`:
|
|
86
|
+
if (legacyResolvedPreset !== undefined) {
|
|
87
|
+
args.resolvedPreset = args.resolvedPreset ?? legacyResolvedPreset;
|
|
88
|
+
}
|
|
89
|
+
if (legacyCtx !== undefined) {
|
|
90
|
+
args.requestContext = args.requestContext ?? legacyCtx;
|
|
91
|
+
}
|
|
92
|
+
const { schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver, resolvedPreset, requestContext, middleware: rawMiddleware, } = args;
|
|
93
|
+
const middleware = rawMiddleware !== undefined
|
|
94
|
+
? rawMiddleware
|
|
95
|
+
: resolvedPreset != null
|
|
96
|
+
? (0, middleware_js_1.getGrafastMiddleware)(resolvedPreset)
|
|
97
|
+
: null;
|
|
88
98
|
// Validate Schema
|
|
89
|
-
const schemaValidationErrors =
|
|
99
|
+
const schemaValidationErrors = middleware != null && resolvedPreset != null
|
|
100
|
+
? middleware.runSync("validateSchema", { schema, resolvedPreset }, validateSchemaWithEvent)
|
|
101
|
+
: validateSchema(schema);
|
|
90
102
|
if (schemaValidationErrors.length > 0) {
|
|
91
103
|
return { errors: schemaValidationErrors };
|
|
92
104
|
}
|
|
93
105
|
// Cached parse and validate
|
|
94
|
-
const documentOrErrors =
|
|
106
|
+
const documentOrErrors = middleware != null && resolvedPreset != null
|
|
107
|
+
? middleware.runSync("parseAndValidate", { resolvedPreset, schema, source }, parseAndValidateWithEvent)
|
|
108
|
+
: parseAndValidate(schema, source);
|
|
95
109
|
if (Array.isArray(documentOrErrors)) {
|
|
96
110
|
return { errors: documentOrErrors };
|
|
97
111
|
}
|
|
@@ -105,23 +119,23 @@ function grafast(args, legacyResolvedPreset, legacyCtx) {
|
|
|
105
119
|
operationName,
|
|
106
120
|
fieldResolver,
|
|
107
121
|
typeResolver,
|
|
122
|
+
middleware,
|
|
123
|
+
resolvedPreset,
|
|
124
|
+
requestContext,
|
|
108
125
|
};
|
|
109
126
|
if (resolvedPreset && requestContext) {
|
|
110
|
-
const argsOrPromise = (0, index_js_1.hookArgs)(executionArgs
|
|
127
|
+
const argsOrPromise = (0, index_js_1.hookArgs)(executionArgs);
|
|
111
128
|
if ((0, utils_js_1.isPromiseLike)(argsOrPromise)) {
|
|
112
|
-
return Promise.resolve(argsOrPromise).then(
|
|
129
|
+
return Promise.resolve(argsOrPromise).then(execute_js_1.execute);
|
|
113
130
|
}
|
|
114
131
|
else {
|
|
115
|
-
|
|
116
|
-
return (0, execute_js_1.execute)(argsOrPromise, resolvedPreset);
|
|
132
|
+
return (0, execute_js_1.execute)(argsOrPromise);
|
|
117
133
|
}
|
|
118
134
|
}
|
|
119
135
|
else {
|
|
120
|
-
|
|
121
|
-
return (0, execute_js_1.execute)(executionArgs, resolvedPreset);
|
|
136
|
+
return (0, execute_js_1.execute)(executionArgs);
|
|
122
137
|
}
|
|
123
138
|
}
|
|
124
|
-
exports.grafast = grafast;
|
|
125
139
|
function grafastSync(args, legacyResolvedPreset, legacyRequestContext) {
|
|
126
140
|
const result = grafast(args, legacyResolvedPreset, legacyRequestContext);
|
|
127
141
|
if ((0, utils_js_1.isPromiseLike)(result)) {
|
|
@@ -129,5 +143,10 @@ function grafastSync(args, legacyResolvedPreset, legacyRequestContext) {
|
|
|
129
143
|
}
|
|
130
144
|
return result;
|
|
131
145
|
}
|
|
132
|
-
|
|
146
|
+
function validateSchemaWithEvent(event) {
|
|
147
|
+
return validateSchema(event.schema);
|
|
148
|
+
}
|
|
149
|
+
function parseAndValidateWithEvent(event) {
|
|
150
|
+
return parseAndValidate(event.schema, event.source);
|
|
151
|
+
}
|
|
133
152
|
//# sourceMappingURL=grafastGraphql.js.map
|
package/dist/grafastPrint.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { Bucket } from "./bucket.js";
|
|
1
2
|
export declare function _grafastPrint(symbol: string | symbol | symbol[] | Record<symbol, any> | Map<any, any>, seen: Set<any>): string;
|
|
3
|
+
export declare function recursivePrintBucket(bucket: Bucket, indentLevel?: number): string;
|
|
4
|
+
export declare function printStore(bucket: Bucket): string;
|
|
2
5
|
export declare function grafastColor(text: string, n: number): string;
|
|
3
6
|
/**
|
|
4
7
|
* Prints something grafast-style (i.e. concise, coloured, with helpful detail)
|
package/dist/grafastPrint.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._grafastPrint = _grafastPrint;
|
|
4
|
+
exports.recursivePrintBucket = recursivePrintBucket;
|
|
5
|
+
exports.printStore = printStore;
|
|
6
|
+
exports.grafastColor = grafastColor;
|
|
7
|
+
exports.grafastPrint = grafastPrint;
|
|
8
|
+
exports.ansiPad = ansiPad;
|
|
4
9
|
const tslib_1 = require("tslib");
|
|
5
10
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
11
|
+
const executeBucket_js_1 = require("./engine/executeBucket.js");
|
|
12
|
+
const OutputPlan_js_1 = require("./engine/OutputPlan.js");
|
|
6
13
|
const inspect_js_1 = require("./inspect.js");
|
|
7
14
|
const step_js_1 = require("./step.js");
|
|
8
15
|
const stripAnsi_js_1 = require("./stripAnsi.js");
|
|
@@ -48,7 +55,7 @@ function _grafastPrint(symbol, seen) {
|
|
|
48
55
|
if (symbol === utils_js_1.ROOT_VALUE_OBJECT) {
|
|
49
56
|
return chalk_1.default.gray `(blank)`;
|
|
50
57
|
}
|
|
51
|
-
if (symbol instanceof step_js_1.
|
|
58
|
+
if (symbol instanceof step_js_1.Step) {
|
|
52
59
|
return String(symbol);
|
|
53
60
|
}
|
|
54
61
|
if (Array.isArray(symbol)) {
|
|
@@ -73,12 +80,18 @@ function _grafastPrint(symbol, seen) {
|
|
|
73
80
|
}
|
|
74
81
|
return `Map{${pairs.join(", ")}}`;
|
|
75
82
|
}
|
|
83
|
+
if (isBucket(symbol)) {
|
|
84
|
+
return recursivePrintBucket(symbol);
|
|
85
|
+
}
|
|
76
86
|
if (typeof symbol === "object" && symbol) {
|
|
77
87
|
if (symbol instanceof Error) {
|
|
78
88
|
return chalk_1.default.red(`ERROR<${(0, stripAnsi_js_1.stripAnsi)(String(symbol.message))
|
|
79
89
|
.replace(/\s+/g, " ")
|
|
80
90
|
.substring(0, 30) + "..."}>`);
|
|
81
91
|
}
|
|
92
|
+
if (symbol instanceof OutputPlan_js_1.OutputPlan) {
|
|
93
|
+
return symbol.print();
|
|
94
|
+
}
|
|
82
95
|
if (![null, Object.prototype, utils_js_1.sharedNull].includes(Object.getPrototypeOf(symbol))) {
|
|
83
96
|
return chalk_1.default.red(`OBJECT<${(0, stripAnsi_js_1.stripAnsi)(String(symbol))}>`);
|
|
84
97
|
}
|
|
@@ -95,7 +108,11 @@ function _grafastPrint(symbol, seen) {
|
|
|
95
108
|
}
|
|
96
109
|
return grafastPrintSymbol(symbol);
|
|
97
110
|
}
|
|
98
|
-
|
|
111
|
+
function isBucket(thing) {
|
|
112
|
+
return (typeof thing === "object" &&
|
|
113
|
+
thing !== null &&
|
|
114
|
+
thing.toString === executeBucket_js_1.bucketToString);
|
|
115
|
+
}
|
|
99
116
|
function _grafastSymbolDescription(symbol) {
|
|
100
117
|
if (!symbol.description) {
|
|
101
118
|
return chalk_1.default.green("Symbol()");
|
|
@@ -109,11 +126,57 @@ function _grafastSymbolDescription(symbol) {
|
|
|
109
126
|
return chalk_1.default.cyan(`$$${symbol.description}`);
|
|
110
127
|
}
|
|
111
128
|
}
|
|
129
|
+
function indent(level, string) {
|
|
130
|
+
return " ".repeat(level) + string.replace(/\n/g, `\n${" ".repeat(level)}`);
|
|
131
|
+
}
|
|
132
|
+
function recursivePrintBucket(bucket, indentLevel = 0) {
|
|
133
|
+
return indent(indentLevel, `Bucket for ${bucket.layerPlan} (size = ${bucket.size}):
|
|
134
|
+
Store:
|
|
135
|
+
${indent(4, printStore(bucket))}
|
|
136
|
+
Children:
|
|
137
|
+
${Object.entries(bucket.children)
|
|
138
|
+
.map(([_id, { bucket }]) => indent(4, recursivePrintBucket(bucket)))
|
|
139
|
+
.join("\n")}`);
|
|
140
|
+
}
|
|
141
|
+
const PRINT_STORE_INSPECT_OPTIONS = {
|
|
142
|
+
colors: true,
|
|
143
|
+
depth: 0,
|
|
144
|
+
showHidden: false,
|
|
145
|
+
maxArrayLength: 5,
|
|
146
|
+
maxStringLength: 50,
|
|
147
|
+
};
|
|
148
|
+
function indentIfMultiline(string) {
|
|
149
|
+
if (string.includes("\n")) {
|
|
150
|
+
return indent(4, "\n" + string);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
return string;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function printStore(bucket) {
|
|
157
|
+
const output = [];
|
|
158
|
+
for (const [key, val] of bucket.store) {
|
|
159
|
+
const printKey = String(key).padStart(3, " ");
|
|
160
|
+
if (bucket.layerPlan.copyStepIds.includes(key)) {
|
|
161
|
+
output.push(`${printKey} (copy)`);
|
|
162
|
+
}
|
|
163
|
+
else if (val.isBatch) {
|
|
164
|
+
const step = bucket.layerPlan.operationPlan.stepTracker.getStepById(key, true);
|
|
165
|
+
output.push(`${printKey} (BATCH): ${step ?? "-"}\n${indent(2, val.entries
|
|
166
|
+
.map((e, i) => `${String(i).padStart(3, " ")}: flags=${String(val._flagsAt(i)).padStart(2, " ")} value=${indentIfMultiline((0, inspect_js_1.inspect)(val.at(i), PRINT_STORE_INSPECT_OPTIONS))}`)
|
|
167
|
+
.join("\n"))}`);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const step = bucket.layerPlan.operationPlan.stepTracker.getStepById(key, true);
|
|
171
|
+
output.push(`${printKey} (UNARY/${String(val._entryFlags).padStart(2, " ")}) ${step ?? "-"}\n${indent(4, (0, inspect_js_1.inspect)(val.value, PRINT_STORE_INSPECT_OPTIONS))}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return output.join("\n") || "EMPTY";
|
|
175
|
+
}
|
|
112
176
|
function grafastColor(text, n) {
|
|
113
177
|
const color = COLORS[Math.abs(n) % COLORS.length];
|
|
114
178
|
return color(text);
|
|
115
179
|
}
|
|
116
|
-
exports.grafastColor = grafastColor;
|
|
117
180
|
const symbolsByAlias = new Map();
|
|
118
181
|
let symbolClear = null;
|
|
119
182
|
/**
|
|
@@ -151,7 +214,6 @@ function grafastPrintSymbol(symbol) {
|
|
|
151
214
|
function grafastPrint(symbol) {
|
|
152
215
|
return _grafastPrint(symbol, new Set());
|
|
153
216
|
}
|
|
154
|
-
exports.grafastPrint = grafastPrint;
|
|
155
217
|
/**
|
|
156
218
|
* An ANSI-aware pad function; strips ANSI sequences from the string, figures
|
|
157
219
|
* out how much it needs to pad it by, and then pads the original string by
|
|
@@ -173,5 +235,4 @@ function ansiPad(ansiString, targetLength, fill, position) {
|
|
|
173
235
|
return ansiString;
|
|
174
236
|
}
|
|
175
237
|
}
|
|
176
|
-
exports.ansiPad = ansiPad;
|
|
177
238
|
//# sourceMappingURL=grafastPrint.js.map
|
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
import type { DirectiveNode
|
|
2
|
-
import * as graphql from "graphql";
|
|
3
|
-
import type { OperationPlan } from "./engine/OperationPlan.js";
|
|
1
|
+
import type { DirectiveNode } from "graphql";
|
|
4
2
|
import type { __TrackedValueStep } from "./steps/index.js";
|
|
5
|
-
/**
|
|
6
|
-
* Given a selection, finds the first directive named `directiveName` and, if
|
|
7
|
-
* found, extracts and returns the value from the argument named
|
|
8
|
-
* `argumentName`, tracking variable access if necessary.
|
|
9
|
-
*
|
|
10
|
-
* @remarks Currently only supports booleans.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*
|
|
14
|
-
* PERF: inline.
|
|
15
|
-
*/
|
|
16
|
-
export declare function evalDirectiveArg<T = unknown>(selection: SelectionNode, directiveName: string, argumentName: string, variableValuesStep: __TrackedValueStep, defaultValue: T): T | undefined;
|
|
17
3
|
export declare function evalDirectiveArgDirect<T = unknown>(directive: DirectiveNode, argumentName: string, variableValuesStep: __TrackedValueStep, defaultValue: T): T | undefined;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
deferred: SelectionSetDigest[] | undefined;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Implements the `GraphQLCollectFields` algorithm - like `CollectFields` the
|
|
28
|
-
* GraphQL spec, but modified such that access to variables is tracked.
|
|
29
|
-
*
|
|
30
|
-
* @see https://spec.graphql.org/draft/#CollectFields()
|
|
31
|
-
*
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
export declare function graphqlCollectFields(operationPlan: OperationPlan, parentStepId: number, objectType: graphql.GraphQLObjectType, selections: readonly SelectionNode[], isMutation?: boolean, visitedFragments?: {
|
|
35
|
-
[fragmentName: string]: true;
|
|
36
|
-
}, selectionSetDigest?: SelectionSetDigest): SelectionSetDigest;
|
|
4
|
+
export declare function newSelectionSetDigest(resolverEmulation: boolean): {
|
|
5
|
+
label: undefined;
|
|
6
|
+
fields: Map<any, any>;
|
|
7
|
+
deferred: undefined;
|
|
8
|
+
resolverEmulation: boolean;
|
|
9
|
+
};
|
|
37
10
|
//# sourceMappingURL=graphqlCollectFields.d.ts.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.evalDirectiveArg = evalDirectiveArg;
|
|
4
|
+
exports.evalDirectiveArgDirect = evalDirectiveArgDirect;
|
|
5
|
+
exports.newSelectionSetDigest = newSelectionSetDigest;
|
|
6
|
+
exports.graphqlCollectFields = graphqlCollectFields;
|
|
4
7
|
const tslib_1 = require("tslib");
|
|
5
8
|
const graphql = tslib_1.__importStar(require("graphql"));
|
|
6
9
|
const error_js_1 = require("./error.js");
|
|
@@ -32,7 +35,6 @@ function evalDirectiveArg(selection, directiveName, argumentName, variableValues
|
|
|
32
35
|
return undefined;
|
|
33
36
|
return evalDirectiveArgDirect(directive, argumentName, variableValuesStep, defaultValue);
|
|
34
37
|
}
|
|
35
|
-
exports.evalDirectiveArg = evalDirectiveArg;
|
|
36
38
|
function evalDirectiveArgDirect(directive, argumentName, variableValuesStep, defaultValue) {
|
|
37
39
|
if (!directive.arguments)
|
|
38
40
|
return defaultValue;
|
|
@@ -49,6 +51,12 @@ function evalDirectiveArgDirect(directive, argumentName, variableValuesStep, def
|
|
|
49
51
|
case "IntValue": {
|
|
50
52
|
return parseInt(value.value, 10);
|
|
51
53
|
}
|
|
54
|
+
case "FloatValue": {
|
|
55
|
+
return parseFloat(value.value);
|
|
56
|
+
}
|
|
57
|
+
case "StringValue": {
|
|
58
|
+
return value.value;
|
|
59
|
+
}
|
|
52
60
|
case "NullValue": {
|
|
53
61
|
return null;
|
|
54
62
|
}
|
|
@@ -61,7 +69,6 @@ function evalDirectiveArgDirect(directive, argumentName, variableValuesStep, def
|
|
|
61
69
|
return defaultValue;
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
|
-
exports.evalDirectiveArgDirect = evalDirectiveArgDirect;
|
|
65
72
|
/**
|
|
66
73
|
* Implements the `DoesFragmentTypeApply` algorithm from the GraphQL
|
|
67
74
|
* specification.
|
|
@@ -90,16 +97,17 @@ const processFragment = (operationPlan, parentStepId, objectType, isMutation, se
|
|
|
90
97
|
const trackedVariableValuesStep = operationPlan.trackedVariableValuesStep;
|
|
91
98
|
const defer = selection.directives?.find((d) => d.name.value === "defer");
|
|
92
99
|
const deferIf = defer
|
|
93
|
-
? evalDirectiveArgDirect(defer, "if", trackedVariableValuesStep, true) ?? true
|
|
100
|
+
? (evalDirectiveArgDirect(defer, "if", trackedVariableValuesStep, true) ?? true)
|
|
94
101
|
: undefined;
|
|
95
102
|
const label = defer
|
|
96
|
-
? evalDirectiveArgDirect(defer, "label", trackedVariableValuesStep, null) ?? undefined
|
|
103
|
+
? (evalDirectiveArgDirect(defer, "label", trackedVariableValuesStep, null) ?? undefined)
|
|
97
104
|
: undefined;
|
|
98
105
|
const deferredDigest = deferIf === true
|
|
99
106
|
? {
|
|
100
107
|
label,
|
|
101
108
|
fields: new Map(),
|
|
102
109
|
deferred: undefined,
|
|
110
|
+
resolverEmulation: selectionSetDigest.resolverEmulation,
|
|
103
111
|
}
|
|
104
112
|
: null;
|
|
105
113
|
if (deferredDigest !== null) {
|
|
@@ -110,8 +118,16 @@ const processFragment = (operationPlan, parentStepId, objectType, isMutation, se
|
|
|
110
118
|
selectionSetDigest.deferred.push(deferredDigest);
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
|
-
graphqlCollectFields(operationPlan, parentStepId, objectType, fragmentSelectionSet.selections,
|
|
121
|
+
graphqlCollectFields(operationPlan, parentStepId, objectType, fragmentSelectionSet.selections, deferredDigest ?? selectionSetDigest, isMutation, visitedFragments);
|
|
114
122
|
};
|
|
123
|
+
function newSelectionSetDigest(resolverEmulation) {
|
|
124
|
+
return {
|
|
125
|
+
label: undefined,
|
|
126
|
+
fields: new Map(),
|
|
127
|
+
deferred: undefined,
|
|
128
|
+
resolverEmulation,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
115
131
|
/**
|
|
116
132
|
* Implements the `GraphQLCollectFields` algorithm - like `CollectFields` the
|
|
117
133
|
* GraphQL spec, but modified such that access to variables is tracked.
|
|
@@ -120,13 +136,9 @@ const processFragment = (operationPlan, parentStepId, objectType, isMutation, se
|
|
|
120
136
|
*
|
|
121
137
|
* @internal
|
|
122
138
|
*/
|
|
123
|
-
function graphqlCollectFields(operationPlan, parentStepId, objectType, selections, isMutation = false,
|
|
139
|
+
function graphqlCollectFields(operationPlan, parentStepId, objectType, selections, selectionSetDigest, isMutation = false,
|
|
124
140
|
// This is significantly faster than an array or a Set
|
|
125
|
-
visitedFragments = Object.create(null)
|
|
126
|
-
label: undefined,
|
|
127
|
-
fields: new Map(),
|
|
128
|
-
deferred: undefined,
|
|
129
|
-
}) {
|
|
141
|
+
visitedFragments = Object.create(null)) {
|
|
130
142
|
// const objectTypeFields = objectType.getFields();
|
|
131
143
|
const trackedVariableValuesStep = operationPlan.trackedVariableValuesStep;
|
|
132
144
|
for (let i = 0, l = selections.length; i < l; i++) {
|
|
@@ -213,5 +225,4 @@ visitedFragments = Object.create(null), selectionSetDigest = {
|
|
|
213
225
|
}
|
|
214
226
|
return selectionSetDigest;
|
|
215
227
|
}
|
|
216
|
-
exports.graphqlCollectFields = graphqlCollectFields;
|
|
217
228
|
//# sourceMappingURL=graphqlCollectFields.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fieldSelectionsForType =
|
|
3
|
+
exports.fieldSelectionsForType = fieldSelectionsForType;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const graphql = tslib_1.__importStar(require("graphql"));
|
|
6
6
|
const inspect_js_1 = require("./inspect.js");
|
|
@@ -56,5 +56,4 @@ function fieldSelectionsForType(operationPlan, type, selections, result = []) {
|
|
|
56
56
|
}
|
|
57
57
|
return result;
|
|
58
58
|
}
|
|
59
|
-
exports.fieldSelectionsForType = fieldSelectionsForType;
|
|
60
59
|
//# sourceMappingURL=graphqlMergeSelectionSets.js.map
|