grafast 0.1.1-beta.21 → 0.1.1-beta.23
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 +7 -7
- 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,6 +1,3 @@
|
|
|
1
1
|
import type { FieldPlanResolver } from "../../interfaces.js";
|
|
2
|
-
|
|
3
|
-
export declare const defaultPlanResolver: FieldPlanResolver<any, Step & {
|
|
4
|
-
get?: (field: string) => Step;
|
|
5
|
-
}, any>;
|
|
2
|
+
export declare const defaultPlanResolver: FieldPlanResolver;
|
|
6
3
|
//# sourceMappingURL=defaultPlanResolver.d.ts.map
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultPlanResolver = void 0;
|
|
4
4
|
const access_js_1 = require("../../steps/access.js");
|
|
5
|
-
const defaultPlanResolver = ($step, _,
|
|
6
|
-
return typeof $step.get === "function"
|
|
7
|
-
? $step.get(fieldName)
|
|
8
|
-
: (0, access_js_1.access)($step, [fieldName]);
|
|
9
|
-
};
|
|
5
|
+
const defaultPlanResolver = ($step, _, info) => (0, access_js_1.get)($step, info.fieldName);
|
|
10
6
|
exports.defaultPlanResolver = defaultPlanResolver;
|
|
11
7
|
//# sourceMappingURL=defaultPlanResolver.js.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Step } from "../..";
|
|
2
2
|
import type { LayerPlan } from "../LayerPlan";
|
|
3
|
-
export declare function withGlobalLayerPlan<T, TThis = any, TArgs extends [...args: any[]] = [...args: any[]]>(layerPlan: LayerPlan, polymorphicPaths: ReadonlySet<string> | null, callback: (this: TThis, ...args: TArgs) => T, callbackThis?: TThis, ...callbackArgs: TArgs): T;
|
|
3
|
+
export declare function withGlobalLayerPlan<T, TThis = any, TArgs extends [...args: any[]] = [...args: any[]]>(layerPlan: LayerPlan, polymorphicPaths: ReadonlySet<string> | null, planningPath: string | null, callback: (this: TThis, ...args: TArgs) => T, callbackThis?: TThis, ...callbackArgs: TArgs): T;
|
|
4
4
|
export declare function currentLayerPlan(): LayerPlan;
|
|
5
5
|
export declare function currentPolymorphicPaths(): ReadonlySet<string> | null;
|
|
6
|
+
/** UNUSED */
|
|
7
|
+
export declare function currentPlanningPath(): string | undefined;
|
|
6
8
|
export declare function isUnaryStep($step: Step): boolean;
|
|
7
9
|
//# sourceMappingURL=withGlobalLayerPlan.d.ts.map
|
|
@@ -3,20 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withGlobalLayerPlan = withGlobalLayerPlan;
|
|
4
4
|
exports.currentLayerPlan = currentLayerPlan;
|
|
5
5
|
exports.currentPolymorphicPaths = currentPolymorphicPaths;
|
|
6
|
+
exports.currentPlanningPath = currentPlanningPath;
|
|
6
7
|
exports.isUnaryStep = isUnaryStep;
|
|
8
|
+
const global_js_1 = require("../../global.js");
|
|
7
9
|
let globalData_layerPlan = undefined;
|
|
8
10
|
let globalData_polymorphicPaths = undefined;
|
|
9
|
-
|
|
11
|
+
let globalData_planningPath = undefined;
|
|
12
|
+
function withGlobalLayerPlan(layerPlan, polymorphicPaths, planningPath, callback, callbackThis, ...callbackArgs) {
|
|
10
13
|
const oldLayerPlan = globalData_layerPlan;
|
|
11
14
|
globalData_layerPlan = layerPlan;
|
|
12
15
|
const oldPolymorphicPaths = globalData_polymorphicPaths;
|
|
13
16
|
globalData_polymorphicPaths = polymorphicPaths;
|
|
17
|
+
const oldPlanningPath = globalData_planningPath;
|
|
18
|
+
// Keep the old planning path if we've not been given a new one
|
|
19
|
+
if (planningPath != null) {
|
|
20
|
+
globalData_planningPath = planningPath;
|
|
21
|
+
}
|
|
14
22
|
try {
|
|
15
23
|
return callback.apply(callbackThis, callbackArgs);
|
|
16
24
|
}
|
|
17
25
|
finally {
|
|
18
26
|
globalData_layerPlan = oldLayerPlan;
|
|
19
27
|
globalData_polymorphicPaths = oldPolymorphicPaths;
|
|
28
|
+
globalData_planningPath = oldPlanningPath;
|
|
20
29
|
}
|
|
21
30
|
}
|
|
22
31
|
function currentLayerPlan() {
|
|
@@ -33,6 +42,15 @@ function currentPolymorphicPaths() {
|
|
|
33
42
|
}
|
|
34
43
|
return globalData_polymorphicPaths;
|
|
35
44
|
}
|
|
45
|
+
/** UNUSED */
|
|
46
|
+
function currentPlanningPath() {
|
|
47
|
+
const opPlan = (0, global_js_1.operationPlan)();
|
|
48
|
+
if (opPlan.phase === "plan" && globalData_planningPath === undefined) {
|
|
49
|
+
// This might happen during deduplicate for example
|
|
50
|
+
console.warn("GrafastInternalWarning<6a484dc3-a690-493c-b8b3-d6196bf2c290>: currentPlanningPath could not retrieve the current path even in 'plan' phase");
|
|
51
|
+
}
|
|
52
|
+
return globalData_planningPath;
|
|
53
|
+
}
|
|
36
54
|
function isUnaryStep($step) {
|
|
37
55
|
return $step._isUnary;
|
|
38
56
|
}
|
package/dist/envelop.js
CHANGED
|
@@ -13,7 +13,7 @@ function processExplain(explainAllowed, explainHeaders) {
|
|
|
13
13
|
const explainHeader = Array.isArray(explainHeaders)
|
|
14
14
|
? explainHeaders.join(",")
|
|
15
15
|
: explainHeaders;
|
|
16
|
-
if (
|
|
16
|
+
if (typeof explainHeader !== "string") {
|
|
17
17
|
return undefined;
|
|
18
18
|
}
|
|
19
19
|
const explainParts = explainHeader.split(",");
|
|
@@ -40,9 +40,20 @@ const useGrafast = (options = {}) => {
|
|
|
40
40
|
},
|
|
41
41
|
async onSubscribe(opts) {
|
|
42
42
|
const ctx = opts.args.contextValue;
|
|
43
|
-
const
|
|
43
|
+
const headersObj = ctx?.req?.headers ||
|
|
44
44
|
ctx?.request?.headers ||
|
|
45
|
-
ctx?.
|
|
45
|
+
ctx?.normalizedConnectionParams ||
|
|
46
|
+
ctx?.connectionParams;
|
|
47
|
+
let explainHeaders;
|
|
48
|
+
if (headersObj) {
|
|
49
|
+
explainHeaders = headersObj["x-graphql-explain"];
|
|
50
|
+
if (explainHeaders == null) {
|
|
51
|
+
const key = Object.keys(headersObj).find((k) => k.toLowerCase() === "x-graphql-explain");
|
|
52
|
+
if (key != null) {
|
|
53
|
+
explainHeaders = headersObj[key];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
46
57
|
const explain = processExplain(explainAllowed, explainHeaders);
|
|
47
58
|
opts.setSubscribeFn(async (args) => (0, subscribe_js_1.subscribe)(args, (0, graphile_config_1.resolvePreset)({
|
|
48
59
|
grafast: { explain },
|
package/dist/error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { $$safeError } from "./constants.js";
|
|
1
2
|
import type { ExecutionEntryFlags } from "./interfaces.js";
|
|
2
|
-
import { $$safeError } from "./interfaces.js";
|
|
3
3
|
declare const $$flagged: unique symbol;
|
|
4
4
|
/**
|
|
5
5
|
* Wrapper for errors to return (rather than throw or reject) from user code.
|
package/dist/error.js
CHANGED
|
@@ -5,15 +5,15 @@ exports.SafeError = exports.$$inhibit = void 0;
|
|
|
5
5
|
exports.flagError = flagError;
|
|
6
6
|
exports.isFlaggedValue = isFlaggedValue;
|
|
7
7
|
exports.isSafeError = isSafeError;
|
|
8
|
+
const constants_js_1 = require("./constants.js");
|
|
8
9
|
const dev_js_1 = require("./dev.js");
|
|
9
10
|
const inspect_js_1 = require("./inspect.js");
|
|
10
|
-
const interfaces_js_1 = require("./interfaces.js");
|
|
11
11
|
const $$flagged = Symbol("grafastFlaggedValue");
|
|
12
12
|
function flaggedValueToString() {
|
|
13
|
-
if (this.flags &
|
|
13
|
+
if (this.flags & constants_js_1.FLAG_ERROR && this.value instanceof Error) {
|
|
14
14
|
return String(this.value);
|
|
15
15
|
}
|
|
16
|
-
else if (this.flags &
|
|
16
|
+
else if (this.flags & constants_js_1.FLAG_INHIBITED && this.value === null) {
|
|
17
17
|
return "INHIBIT";
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
@@ -22,10 +22,10 @@ function flaggedValueToString() {
|
|
|
22
22
|
}
|
|
23
23
|
function flaggedValue(flags, value, planId) {
|
|
24
24
|
if (dev_js_1.isDev) {
|
|
25
|
-
if (value === null && !(flags &
|
|
25
|
+
if (value === null && !(flags & constants_js_1.FLAG_NULL)) {
|
|
26
26
|
throw new Error(`flaggedValue called with null, but not flagged as null.`);
|
|
27
27
|
}
|
|
28
|
-
if (value === null && !(flags &
|
|
28
|
+
if (value === null && !(flags & constants_js_1.FLAG_INHIBITED)) {
|
|
29
29
|
throw new Error(`flaggedValue called with null, but not flagged as inhibited.`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -37,13 +37,13 @@ function flaggedValue(flags, value, planId) {
|
|
|
37
37
|
toString: flaggedValueToString,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
exports.$$inhibit = flaggedValue(
|
|
40
|
+
exports.$$inhibit = flaggedValue(constants_js_1.FLAG_NULL | constants_js_1.FLAG_INHIBITED, null, null);
|
|
41
41
|
/**
|
|
42
42
|
* Used to wrap error values to have Grafast treat them as if they were
|
|
43
43
|
* thrown/rejected (rather than just regular values).
|
|
44
44
|
*/
|
|
45
45
|
function flagError(value, planId = null) {
|
|
46
|
-
return flaggedValue(
|
|
46
|
+
return flaggedValue(constants_js_1.FLAG_ERROR, value, planId);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Is this a flagged value?
|
|
@@ -54,7 +54,7 @@ function isFlaggedValue(value) {
|
|
|
54
54
|
return Object.hasOwn(value, $$flagged);
|
|
55
55
|
}
|
|
56
56
|
class SafeError extends Error {
|
|
57
|
-
static { _a =
|
|
57
|
+
static { _a = constants_js_1.$$safeError; }
|
|
58
58
|
static { this.$$export = {
|
|
59
59
|
moduleName: "grafast",
|
|
60
60
|
exportName: "SafeError",
|
|
@@ -68,6 +68,6 @@ class SafeError extends Error {
|
|
|
68
68
|
}
|
|
69
69
|
exports.SafeError = SafeError;
|
|
70
70
|
function isSafeError(error) {
|
|
71
|
-
return error[
|
|
71
|
+
return error[constants_js_1.$$safeError];
|
|
72
72
|
}
|
|
73
73
|
//# sourceMappingURL=error.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GraphQLSchema, OperationDefinitionNode } from "graphql";
|
|
2
2
|
import { OperationPlan } from "./index.js";
|
|
3
3
|
import type { BaseGraphQLRootValue, BaseGraphQLVariables, Fragments } from "./interfaces.js";
|
|
4
|
+
import type { GrafastOperationOptions } from "./prepare.js";
|
|
4
5
|
/**
|
|
5
6
|
* Implements the `EstablishOpPlan` algorithm.
|
|
6
7
|
*
|
|
@@ -8,5 +9,5 @@ import type { BaseGraphQLRootValue, BaseGraphQLVariables, Fragments } from "./in
|
|
|
8
9
|
* instead accept operation and fragments since they're easier to get a hold of
|
|
9
10
|
* in GraphQL.js.
|
|
10
11
|
*/
|
|
11
|
-
export declare function establishOperationPlan<TVariables extends BaseGraphQLVariables = BaseGraphQLVariables, TContext extends Grafast.Context = Grafast.Context, TRootValue extends BaseGraphQLRootValue = BaseGraphQLRootValue>(schema: GraphQLSchema, operation: OperationDefinitionNode, fragments: Fragments, variableValues: TVariables, context: TContext, rootValue: TRootValue,
|
|
12
|
+
export declare function establishOperationPlan<TVariables extends BaseGraphQLVariables = BaseGraphQLVariables, TContext extends Grafast.Context = Grafast.Context, TRootValue extends BaseGraphQLRootValue = BaseGraphQLRootValue>(schema: GraphQLSchema, operation: OperationDefinitionNode, fragments: Fragments, variableValues: TVariables, context: TContext, rootValue: TRootValue, options: GrafastOperationOptions): OperationPlan;
|
|
12
13
|
//# sourceMappingURL=establishOperationPlan.d.ts.map
|
|
@@ -4,10 +4,10 @@ exports.establishOperationPlan = establishOperationPlan;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const lru_1 = tslib_1.__importDefault(require("@graphile/lru"));
|
|
6
6
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
7
|
+
const constants_js_1 = require("./constants.js");
|
|
7
8
|
const constraints_js_1 = require("./constraints.js");
|
|
8
9
|
const dev_js_1 = require("./dev.js");
|
|
9
10
|
const index_js_1 = require("./index.js");
|
|
10
|
-
const interfaces_js_1 = require("./interfaces.js");
|
|
11
11
|
const timeSource_js_1 = require("./timeSource.js");
|
|
12
12
|
const debug = (0, debug_1.default)("grafast:establishOperationPlan");
|
|
13
13
|
// How long is a timeout valid for? Here I've set it to 60 seconds.
|
|
@@ -70,9 +70,9 @@ function isOperationPlanResultCompatible(operationPlan, variableValues, context,
|
|
|
70
70
|
* instead accept operation and fragments since they're easier to get a hold of
|
|
71
71
|
* in GraphQL.js.
|
|
72
72
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let cacheByOperation = schema.extensions.grafast?.[
|
|
73
|
+
function establishOperationPlan(schema, operation, fragments, variableValues, context, rootValue, options) {
|
|
74
|
+
const planningTimeout = options.timeouts?.planning;
|
|
75
|
+
let cacheByOperation = schema.extensions.grafast?.[constants_js_1.$$cacheByOperation];
|
|
76
76
|
let cache = cacheByOperation?.get(operation);
|
|
77
77
|
// These two variables to make it easy to trim the linked list later.
|
|
78
78
|
let count = 0;
|
|
@@ -88,8 +88,8 @@ function establishOperationPlan(schema, operation, fragments, variableValues, co
|
|
|
88
88
|
const { error, operationPlan } = value;
|
|
89
89
|
if (error != null) {
|
|
90
90
|
if (error instanceof index_js_1.SafeError) {
|
|
91
|
-
if (error.extensions?.[
|
|
92
|
-
if (error.extensions[
|
|
91
|
+
if (error.extensions?.[constants_js_1.$$timeout] != null) {
|
|
92
|
+
if (error.extensions[constants_js_1.$$ts] < timeSource_js_1.timeSource.now() - TIMEOUT_TIMEOUT) {
|
|
93
93
|
// Remove this out of date timeout
|
|
94
94
|
linkedItem = linkedItem.next;
|
|
95
95
|
if (previousItem !== null) {
|
|
@@ -100,8 +100,8 @@ function establishOperationPlan(schema, operation, fragments, variableValues, co
|
|
|
100
100
|
}
|
|
101
101
|
continue;
|
|
102
102
|
}
|
|
103
|
-
if (planningTimeout
|
|
104
|
-
error.extensions[
|
|
103
|
+
if (planningTimeout != null &&
|
|
104
|
+
error.extensions[constants_js_1.$$timeout] >= planningTimeout) {
|
|
105
105
|
// It was a timeout error - do not retry
|
|
106
106
|
throw error;
|
|
107
107
|
}
|
|
@@ -146,7 +146,7 @@ function establishOperationPlan(schema, operation, fragments, variableValues, co
|
|
|
146
146
|
const contextConstraints = [];
|
|
147
147
|
const rootValueConstraints = [];
|
|
148
148
|
try {
|
|
149
|
-
operationPlan = new index_js_1.OperationPlan(schema, operation, fragments, variableValuesConstraints, variableValues, contextConstraints, context, rootValueConstraints, rootValue,
|
|
149
|
+
operationPlan = new index_js_1.OperationPlan(schema, operation, fragments, variableValuesConstraints, variableValues, contextConstraints, context, rootValueConstraints, rootValue, options);
|
|
150
150
|
}
|
|
151
151
|
catch (e) {
|
|
152
152
|
error = e;
|
|
@@ -159,7 +159,7 @@ function establishOperationPlan(schema, operation, fragments, variableValues, co
|
|
|
159
159
|
cacheByOperation = new lru_1.default({
|
|
160
160
|
maxLength: schema.extensions.grafast.operationsCacheMaxLength ?? 500,
|
|
161
161
|
});
|
|
162
|
-
schema.extensions.grafast[
|
|
162
|
+
schema.extensions.grafast[constants_js_1.$$cacheByOperation] = cacheByOperation;
|
|
163
163
|
}
|
|
164
164
|
const establishOperationPlanResult = {
|
|
165
165
|
variableValuesConstraints,
|
package/dist/execute.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.withGrafastArgs = withGrafastArgs;
|
|
|
4
4
|
exports.execute = execute;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const eventemitter3_1 = tslib_1.__importDefault(require("eventemitter3"));
|
|
7
|
+
const constants_js_1 = require("./constants.js");
|
|
7
8
|
const dev_js_1 = require("./dev.js");
|
|
8
9
|
const inspect_js_1 = require("./inspect.js");
|
|
9
|
-
const interfaces_js_1 = require("./interfaces.js");
|
|
10
10
|
const middleware_js_1 = require("./middleware.js");
|
|
11
11
|
const prepare_js_1 = require("./prepare.js");
|
|
12
12
|
const utils_js_1 = require("./utils.js");
|
|
@@ -36,8 +36,8 @@ function withGrafastArgs(args) {
|
|
|
36
36
|
const eventEmitter = new eventemitter3_1.default();
|
|
37
37
|
const explainOperations = [];
|
|
38
38
|
args.rootValue = Object.assign(Object.create(null), args.rootValue, {
|
|
39
|
-
[
|
|
40
|
-
[
|
|
39
|
+
[constants_js_1.$$eventEmitter]: eventEmitter,
|
|
40
|
+
[constants_js_1.$$extensions]: {
|
|
41
41
|
explain: {
|
|
42
42
|
operations: explainOperations,
|
|
43
43
|
},
|
|
@@ -53,12 +53,14 @@ function withGrafastArgs(args) {
|
|
|
53
53
|
eventEmitter.removeListener("explainOperation", handleExplainOperation);
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const operationOptions = {
|
|
57
57
|
explain: options?.explain,
|
|
58
58
|
timeouts: options?.timeouts,
|
|
59
|
+
maxPlanningDepth: options?.maxPlanningDepth,
|
|
59
60
|
// TODO: Delete this
|
|
60
61
|
outputDataAsString: args.outputDataAsString,
|
|
61
|
-
}
|
|
62
|
+
};
|
|
63
|
+
const rootValue = (0, prepare_js_1.grafastPrepare)(args, operationOptions);
|
|
62
64
|
if (unlisten !== null) {
|
|
63
65
|
Promise.resolve(rootValue).then(unlisten, unlisten);
|
|
64
66
|
}
|
package/dist/global.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import type { OperationPlan } from "./engine/OperationPlan.js";
|
|
2
|
+
import type { __ValueStep } from "./steps/index.js";
|
|
1
3
|
export declare function setDebug(newDebug: boolean): void;
|
|
2
4
|
export declare function getDebug(): boolean;
|
|
5
|
+
export declare function operationPlan(): OperationPlan;
|
|
6
|
+
export declare function context(): __ValueStep<Grafast.Context>;
|
|
7
|
+
export declare function rootValue(): __ValueStep<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;
|
|
3
13
|
//# sourceMappingURL=global.d.ts.map
|
package/dist/global.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setDebug = setDebug;
|
|
4
4
|
exports.getDebug = getDebug;
|
|
5
|
+
exports.operationPlan = operationPlan;
|
|
6
|
+
exports.context = context;
|
|
7
|
+
exports.rootValue = rootValue;
|
|
8
|
+
exports.debugPlans = debugPlans;
|
|
9
|
+
const withGlobalLayerPlan_js_1 = require("./engine/lib/withGlobalLayerPlan.js");
|
|
5
10
|
let debug = false;
|
|
6
11
|
function setDebug(newDebug) {
|
|
7
12
|
debug = newDebug;
|
|
@@ -9,4 +14,24 @@ function setDebug(newDebug) {
|
|
|
9
14
|
function getDebug() {
|
|
10
15
|
return debug;
|
|
11
16
|
}
|
|
17
|
+
function operationPlan() {
|
|
18
|
+
return (0, withGlobalLayerPlan_js_1.currentLayerPlan)().operationPlan;
|
|
19
|
+
}
|
|
20
|
+
function context() {
|
|
21
|
+
return operationPlan().contextStep;
|
|
22
|
+
}
|
|
23
|
+
function rootValue() {
|
|
24
|
+
return operationPlan().rootValueStep;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Turns on debug mode, calls the callback, and then turns debug mode back off
|
|
28
|
+
* again.
|
|
29
|
+
*/
|
|
30
|
+
function debugPlans(callback) {
|
|
31
|
+
const oldDebug = getDebug();
|
|
32
|
+
setDebug(true);
|
|
33
|
+
const result = callback();
|
|
34
|
+
setDebug(oldDebug);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
12
37
|
//# sourceMappingURL=global.js.map
|
package/dist/grafastGraphql.js
CHANGED
|
@@ -5,10 +5,10 @@ exports.grafastSync = grafastSync;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const lru_1 = tslib_1.__importDefault(require("@graphile/lru"));
|
|
7
7
|
const graphql = tslib_1.__importStar(require("graphql"));
|
|
8
|
+
const constants_js_1 = require("./constants.js");
|
|
8
9
|
const error_js_1 = require("./error.js");
|
|
9
10
|
const execute_js_1 = require("./execute.js");
|
|
10
11
|
const index_js_1 = require("./index.js");
|
|
11
|
-
const interfaces_js_1 = require("./interfaces.js");
|
|
12
12
|
const middleware_js_1 = require("./middleware.js");
|
|
13
13
|
const utils_js_1 = require("./utils.js");
|
|
14
14
|
const { GraphQLError, parse, Source, validate, validateSchema } = graphql;
|
|
@@ -22,6 +22,7 @@ let calculateQueryHash;
|
|
|
22
22
|
try {
|
|
23
23
|
let lastString;
|
|
24
24
|
let lastHash;
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
25
26
|
const createHash = require("crypto").createHash;
|
|
26
27
|
if (typeof createHash !== "function") {
|
|
27
28
|
throw new Error("Failed to load createHash");
|
|
@@ -38,7 +39,7 @@ catch {
|
|
|
38
39
|
calculateQueryHash = (str) => str;
|
|
39
40
|
}
|
|
40
41
|
const parseAndValidate = (gqlSchema, stringOrSource) => {
|
|
41
|
-
let queryCache = gqlSchema.extensions.grafast?.[
|
|
42
|
+
let queryCache = gqlSchema.extensions.grafast?.[constants_js_1.$$queryCache];
|
|
42
43
|
if (!queryCache) {
|
|
43
44
|
const cacheSize = gqlSchema.extensions.grafast?.queryCacheMaxLength ??
|
|
44
45
|
defaultQueryCacheMaxSize;
|
|
@@ -46,7 +47,7 @@ const parseAndValidate = (gqlSchema, stringOrSource) => {
|
|
|
46
47
|
if (!gqlSchema.extensions.grafast) {
|
|
47
48
|
gqlSchema.extensions.grafast = Object.create(null);
|
|
48
49
|
}
|
|
49
|
-
gqlSchema.extensions.grafast[
|
|
50
|
+
gqlSchema.extensions.grafast[constants_js_1.$$queryCache] = queryCache;
|
|
50
51
|
}
|
|
51
52
|
// Only cache queries that are less than 100kB, we don't want DOS attacks
|
|
52
53
|
// attempting to exhaust our memory.
|
package/dist/grafastPrint.js
CHANGED
|
@@ -8,7 +8,9 @@ exports.grafastPrint = grafastPrint;
|
|
|
8
8
|
exports.ansiPad = ansiPad;
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
11
|
+
const constants_js_1 = require("./constants.js");
|
|
11
12
|
const executeBucket_js_1 = require("./engine/executeBucket.js");
|
|
13
|
+
const LayerPlan_js_1 = require("./engine/LayerPlan.js");
|
|
12
14
|
const OutputPlan_js_1 = require("./engine/OutputPlan.js");
|
|
13
15
|
const inspect_js_1 = require("./inspect.js");
|
|
14
16
|
const step_js_1 = require("./step.js");
|
|
@@ -58,6 +60,9 @@ function _grafastPrint(symbol, seen) {
|
|
|
58
60
|
if (symbol instanceof step_js_1.Step) {
|
|
59
61
|
return String(symbol);
|
|
60
62
|
}
|
|
63
|
+
if (symbol instanceof LayerPlan_js_1.LayerPlan) {
|
|
64
|
+
return String(symbol);
|
|
65
|
+
}
|
|
61
66
|
if (Array.isArray(symbol)) {
|
|
62
67
|
if (seen.has(symbol)) {
|
|
63
68
|
return chalk_1.default.gray `(loop)`;
|
|
@@ -130,7 +135,10 @@ function indent(level, string) {
|
|
|
130
135
|
return " ".repeat(level) + string.replace(/\n/g, `\n${" ".repeat(level)}`);
|
|
131
136
|
}
|
|
132
137
|
function recursivePrintBucket(bucket, indentLevel = 0) {
|
|
133
|
-
return indent(indentLevel, `Bucket for ${bucket.layerPlan} (size = ${bucket.size})
|
|
138
|
+
return indent(indentLevel, `Bucket for ${bucket.layerPlan} (size = ${bucket.size}):${bucket.polymorphicPathList.some((p) => p != null)
|
|
139
|
+
? `
|
|
140
|
+
${bucket.polymorphicPathList.map((p, i) => `${String(i).padStart(4, " ")}: ${p}`)}`
|
|
141
|
+
: ""}
|
|
134
142
|
Store:
|
|
135
143
|
${indent(4, printStore(bucket))}
|
|
136
144
|
Children:
|
|
@@ -162,13 +170,13 @@ function printStore(bucket) {
|
|
|
162
170
|
}
|
|
163
171
|
else if (val.isBatch) {
|
|
164
172
|
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=${
|
|
173
|
+
output.push(`${printKey} (BATCH): ${step ?? "-"} ${[...(step?.polymorphicPaths ?? [])]}\n${indent(2, val.entries
|
|
174
|
+
.map((e, i) => `${String(i).padStart(3, " ")}: flags=${printFlags(val._flagsAt(i))} value=${indentIfMultiline((0, inspect_js_1.inspect)(val.at(i), PRINT_STORE_INSPECT_OPTIONS))}`)
|
|
167
175
|
.join("\n"))}`);
|
|
168
176
|
}
|
|
169
177
|
else {
|
|
170
178
|
const step = bucket.layerPlan.operationPlan.stepTracker.getStepById(key, true);
|
|
171
|
-
output.push(`${printKey} (UNARY/${
|
|
179
|
+
output.push(`${printKey} (UNARY/${printFlags(val._entryFlags)}) ${step ?? "-"} ${[...(step?.polymorphicPaths ?? [])]}\n${indent(4, (0, inspect_js_1.inspect)(val.value, PRINT_STORE_INSPECT_OPTIONS))}`);
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
182
|
return output.join("\n") || "EMPTY";
|
|
@@ -235,4 +243,28 @@ function ansiPad(ansiString, targetLength, fill, position) {
|
|
|
235
243
|
return ansiString;
|
|
236
244
|
}
|
|
237
245
|
}
|
|
246
|
+
function printFlags(flags) {
|
|
247
|
+
if (flags === undefined)
|
|
248
|
+
return " ? ";
|
|
249
|
+
if (flags === 0)
|
|
250
|
+
return " ";
|
|
251
|
+
// This should not fire, added in case we add future flags and forget to update this
|
|
252
|
+
if (flags !==
|
|
253
|
+
(flags &
|
|
254
|
+
(constants_js_1.FLAG_POLY_SKIPPED |
|
|
255
|
+
constants_js_1.FLAG_ERROR |
|
|
256
|
+
constants_js_1.FLAG_NULL |
|
|
257
|
+
constants_js_1.FLAG_INHIBITED |
|
|
258
|
+
constants_js_1.FLAG_STOPPED))) {
|
|
259
|
+
return String(flags).padStart(5, " ");
|
|
260
|
+
}
|
|
261
|
+
let flagString = "";
|
|
262
|
+
// Alphabetically sorted to avoid an unfortunate word they would spell
|
|
263
|
+
flagString += flags & constants_js_1.FLAG_ERROR ? "E" : " ";
|
|
264
|
+
flagString += flags & constants_js_1.FLAG_INHIBITED ? "I" : " ";
|
|
265
|
+
flagString += flags & constants_js_1.FLAG_NULL ? "N" : " ";
|
|
266
|
+
flagString += flags & constants_js_1.FLAG_POLY_SKIPPED ? "P" : " ";
|
|
267
|
+
flagString += flags & constants_js_1.FLAG_STOPPED ? "S" : " ";
|
|
268
|
+
return flagString;
|
|
269
|
+
}
|
|
238
270
|
//# sourceMappingURL=grafastPrint.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import type { DataFromObjectSteps } from "./steps/object.js";
|
|
|
6
6
|
type PromiseOrValue<T> = T | Promise<T>;
|
|
7
7
|
import { exportAs, exportAsMany } from "./exportAs.js";
|
|
8
8
|
import { grafastPrint } from "./grafastPrint.js";
|
|
9
|
-
import {
|
|
9
|
+
import { AbstractTypePlan, DeprecatedInputObjectPlan, DeprecatedObjectPlan, EnumPlan, EnumValueConfig, EnumValueInput, FieldPlan, GrafastSchemaConfig, InputFieldPlan, InputObjectPlan, InterfacePlan, makeGrafastSchema, ObjectFieldConfig, ObjectPlan, ScalarPlan, UnionPlan } from "./makeGrafastSchema.js";
|
|
10
|
+
import type { $$cacheByOperation, $$hooked, $$queryCache } from "./constants.js";
|
|
11
|
+
import { $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$verbatim, DEFAULT_ACCEPT_FLAGS } from "./constants.js";
|
|
10
12
|
import { defer, Deferred } from "./deferred.js";
|
|
11
13
|
import { isDev, noop } from "./dev.js";
|
|
12
14
|
import { defaultPlanResolver } from "./engine/lib/defaultPlanResolver.js";
|
|
@@ -14,22 +16,22 @@ import { isUnaryStep } from "./engine/lib/withGlobalLayerPlan.js";
|
|
|
14
16
|
import { OperationPlan } from "./engine/OperationPlan.js";
|
|
15
17
|
import { $$inhibit, flagError, isSafeError, SafeError } from "./error.js";
|
|
16
18
|
import { execute } from "./execute.js";
|
|
19
|
+
import { context, debugPlans, operationPlan, rootValue } from "./global.js";
|
|
17
20
|
import { grafast, grafastSync } from "./grafastGraphql.js";
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
21
|
+
import { inspect } from "./inspect.js";
|
|
22
|
+
import type { AbstractTypePlanner, ArgumentApplyPlanResolver, BaseEventMap, BaseGraphQLArguments, BaseGraphQLRootValue, BaseGraphQLVariables, BatchExecutionValue, CacheByOperationEntry, DataFromStep, EnumValueApplyResolver, EstablishOperationPlanEvent, EventCallback, EventMapKey, ExecuteEvent, ExecuteStepEvent, ExecutionDetails, ExecutionDetailsStream, ExecutionEventEmitter, ExecutionEventMap, ExecutionExtra, ExecutionResults, ExecutionResultValue, ExecutionValue, FieldArg, FieldArgs, FieldInfo, FieldPlanResolver, GrafastArgumentConfig, GrafastExecutionArgs, GrafastFieldConfig, GrafastFieldConfigArgumentMap, GrafastInputFieldConfig, GrafastPlanJSON, GrafastResultsList, GrafastResultStreamList, GrafastSubscriber, GrafastTimeouts, GrafastValuesList, InputObjectFieldApplyResolver, InputObjectTypeBakedInfo, InputObjectTypeBakedResolver, JSONArray, JSONObject, JSONValue, Maybe, NodeIdCodec, NodeIdHandler, ParseAndValidateEvent, PlanTypeInfo, PrepareArgsEvent, PromiseOrDirect, ScalarInputPlanResolver, ScalarPlanResolver, StepOptimizeOptions, StepStreamOptions, TypedEventEmitter, UnaryExecutionValue, UnbatchedExecutionExtra, ValidateSchemaEvent } from "./interfaces.js";
|
|
20
23
|
import { getGrafastMiddleware } from "./middleware.js";
|
|
21
24
|
import type { Multistep, UnwrapMultistep } from "./multistep.js";
|
|
22
25
|
import { multistep } from "./multistep.js";
|
|
23
26
|
import { getNullableInputTypeAtPath } from "./operationPlan-input.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { __FlagStep, __InputListStep, __InputObjectStep, __InputObjectStepWithDollars, __InputStaticLeafStep, __ItemStep, __ListTransformStep, __TrackedValueStep, __TrackedValueStepWithDollars, __ValueStep, access, AccessStep, ActualKeyByDesiredKey, applyInput, ApplyInputStep, applyTransforms, ApplyTransformsStep, assertEdgeCapableStep, assertModifier, assertNotNull, assertPageInfoCapableStep, bakedInput, bakedInputRuntime, BakedInputStep, condition, ConditionStep, connection, ConnectionCapableStep, ConnectionStep, constant, ConstantStep, context, createObjectAndApplyChildren, debugPlans, each, EdgeCapableStep, EdgeStep, error, ErrorStep, filter, FilterPlanMemo, first, FirstStep, GraphQLItemHandler, graphqlItemHandler, graphqlResolver, GraphQLResolverStep, groupBy, GroupByPlanMemo, inhibitOnNull, isModifier, lambda, LambdaStep, last, LastStep, list, listen, ListenStep, ListStep, listTransform, ListTransformItemPlanCallback, ListTransformOptions, ListTransformReduce, LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, loadOne, LoadOneCallback, loadOneCallback, LoadOptions, LoadStep, makeDecodeNodeId, makeDecodeNodeIdRuntime, Modifier, node, nodeIdFromNode, NodeStep, object, ObjectPlanMeta, ObjectStep, operationPlan, PageInfoCapableStep, partitionByIndex, polymorphicBranch, PolymorphicBranchMatcher, PolymorphicBranchMatchers, PolymorphicBranchStep, proxy, ProxyStep, remapKeys, RemapKeysStep, reverse, reverseArray, ReverseStep, rootValue, Setter, setter, SetterCapable, sideEffect, SideEffectStep, specFromNodeId, trackedContext, trackedRootValue, trap, TRAP_ERROR, TRAP_ERROR_OR_INHIBITED, TRAP_INHIBITED } from "./steps/index.js";
|
|
27
|
+
import { assertExecutableStep, assertListCapableStep, assertStep, isExecutableStep, isListCapableStep, isListLikeStep, isObjectLikeStep, isStep, ListCapableStep, ListLikeStep, ObjectLikeStep, Step, UnbatchedStep } from "./step.js";
|
|
28
|
+
import { __FlagStep, __InputListStep, __InputObjectStep, __InputObjectStepWithDollars, __InputStaticLeafStep, __ItemStep, __ListTransformStep, __TrackedValueStep, __TrackedValueStepWithDollars, __ValueStep, access, AccessStep, ActualKeyByDesiredKey, applyInput, ApplyInputStep, applyTransforms, ApplyTransformsStep, assertEdgeCapableStep, assertModifier, assertNotNull, assertPageInfoCapableStep, bakedInput, bakedInputRuntime, BakedInputStep, coalesce, CoalesceStep, condition, ConditionStep, connection, ConnectionCapableStep, ConnectionStep, constant, ConstantStep, createObjectAndApplyChildren, each, EdgeCapableStep, EdgeStep, error, ErrorStep, filter, FilterPlanMemo, first, FirstStep, get, graphqlResolver, GraphQLResolverStep, groupBy, GroupByPlanMemo, inhibitOnNull, isModifier, lambda, LambdaStep, last, LastStep, list, listen, ListenStep, ListStep, listTransform, ListTransformItemPlanCallback, ListTransformOptions, ListTransformReduce, LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, loadOne, LoadOneCallback, loadOneCallback, LoadOptions, LoadStep, makeDecodeNodeId, makeDecodeNodeIdRuntime, Modifier, node, nodeIdFromNode, NodeStep, object, ObjectPlanMeta, ObjectStep, PageInfoCapableStep, partitionByIndex, proxy, ProxyStep, remapKeys, RemapKeysStep, reverse, reverseArray, ReverseStep, Setter, setter, SetterCapable, sideEffect, SideEffectStep, specFromNodeId, trap, TRAP_ERROR, TRAP_ERROR_OR_INHIBITED, TRAP_INHIBITED } from "./steps/index.js";
|
|
27
29
|
import { stringifyPayload } from "./stringifyPayload.js";
|
|
28
30
|
import { stripAnsi } from "./stripAnsi.js";
|
|
29
31
|
import { subscribe } from "./subscribe.js";
|
|
30
|
-
import { arrayOfLength, arraysMatch, getEnumValueConfig, getEnumValueConfigs, GrafastInputFieldConfigMap, GrafastInputObjectType, GrafastObjectType, inputObjectFieldSpec, InputObjectTypeSpec, isPromiseLike, newGrafastFieldConfigBuilder, newInputObjectTypeBuilder, newObjectTypeBuilder, objectFieldSpec, objectSpec, ObjectTypeFields, ObjectTypeSpec, stepADependsOnStepB, stepAMayDependOnStepB, stepsAreInSamePhase } from "./utils.js";
|
|
32
|
+
import { arrayOfLength, arraysMatch, getEnumValueConfig, getEnumValueConfigs, GrafastInputFieldConfigMap, GrafastInputObjectType, GrafastObjectType, inputObjectFieldSpec, InputObjectTypeSpec, isPromiseLike, mapsMatch, newGrafastFieldConfigBuilder, newInputObjectTypeBuilder, newObjectTypeBuilder, objectFieldSpec, objectSpec, ObjectTypeFields, ObjectTypeSpec, recordsMatch, setsMatch, stepADependsOnStepB, stepAMayDependOnStepB, stepAShouldTryAndInlineIntoStepB, stepsAreInSamePhase } from "./utils.js";
|
|
31
33
|
export { isAsyncIterable } from "iterall";
|
|
32
|
-
export { __FlagStep, __InputListStep, __InputObjectStep, __InputObjectStepWithDollars, __InputStaticLeafStep, __ItemStep, __ListTransformStep, __TrackedValueStep, __TrackedValueStepWithDollars, __ValueStep, $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$inhibit, $$verbatim, access, AccessStep, ActualKeyByDesiredKey, applyInput, ApplyInputStep, applyTransforms, ApplyTransformsStep, arrayOfLength, arraysMatch, assertEdgeCapableStep, assertExecutableStep, assertListCapableStep, assertModifier, assertNotNull, assertPageInfoCapableStep, assertStep, bakedInput, bakedInputRuntime, BakedInputStep, BaseEventMap, BaseGraphQLArguments, BaseGraphQLRootValue, BaseGraphQLVariables, BatchExecutionValue, condition, ConditionStep, connection, ConnectionCapableStep, ConnectionStep, constant, ConstantStep, context, createObjectAndApplyChildren, DataFromObjectSteps, DataFromStep, debugPlans, defaultPlanResolver, defer, Deferred, each, EdgeCapableStep, EdgeStep,
|
|
34
|
+
export { __FlagStep, __InputListStep, __InputObjectStep, __InputObjectStepWithDollars, __InputStaticLeafStep, __ItemStep, __ListTransformStep, __TrackedValueStep, __TrackedValueStepWithDollars, __ValueStep, $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$inhibit, $$verbatim, AbstractTypePlan, AbstractTypePlanner, access, AccessStep, ActualKeyByDesiredKey, applyInput, ApplyInputStep, applyTransforms, ApplyTransformsStep, arrayOfLength, arraysMatch, assertEdgeCapableStep, assertExecutableStep, assertListCapableStep, assertModifier, assertNotNull, assertPageInfoCapableStep, assertStep, bakedInput, bakedInputRuntime, BakedInputStep, BaseEventMap, BaseGraphQLArguments, BaseGraphQLRootValue, BaseGraphQLVariables, BatchExecutionValue, coalesce, CoalesceStep, condition, ConditionStep, connection, ConnectionCapableStep, ConnectionStep, constant, ConstantStep, context, createObjectAndApplyChildren, DataFromObjectSteps, DataFromStep, debugPlans, DEFAULT_ACCEPT_FLAGS, defaultPlanResolver, defer, Deferred, DeprecatedInputObjectPlan, DeprecatedObjectPlan, each, EdgeCapableStep, EdgeStep, EnumPlan, EnumValueConfig, EnumValueInput, error, ErrorStep, EventCallback, EventMapKey, Step as ExecutableStep, execute, ExecutionDetails, ExecutionDetailsStream, ExecutionEventEmitter, ExecutionEventMap, ExecutionExtra, ExecutionResults, ExecutionResultValue, ExecutionValue, exportAs, exportAsMany, FieldArg, FieldArgs, FieldInfo, FieldPlan, FieldPlanResolver, filter, FilterPlanMemo, first, FirstStep, flagError, get, getEnumValueConfig, getEnumValueConfigs, getGrafastMiddleware, getNullableInputTypeAtPath, grafast, GrafastArgumentConfig, GrafastExecutionArgs, GrafastFieldConfig, GrafastFieldConfigArgumentMap, grafast as grafastGraphql, grafastSync as grafastGraphqlSync, GrafastInputFieldConfig, GrafastInputFieldConfigMap, GrafastInputObjectType, GrafastObjectType, GrafastPlanJSON, grafastPrint, GrafastResultsList, GrafastResultStreamList, GrafastSchemaConfig, GrafastSubscriber, grafastSync, GrafastValuesList, graphqlResolver, GraphQLResolverStep, groupBy, GroupByPlanMemo, inhibitOnNull, InputFieldPlan, InputObjectFieldApplyResolver, inputObjectFieldSpec, InputObjectPlan, InputObjectTypeBakedInfo, InputObjectTypeBakedResolver, InputObjectTypeSpec, inspect, AbstractTypePlan as InterfaceOrUnionPlans, InterfacePlan, isDev, isExecutableStep, isListCapableStep, isListLikeStep, isModifier, isObjectLikeStep, isPromiseLike, isSafeError, isStep, isUnaryStep, JSONArray, JSONObject, JSONValue, lambda, LambdaStep, last, LastStep, list, ListCapableStep, listen, ListenStep, ListLikeStep, ListStep, listTransform, ListTransformItemPlanCallback, ListTransformOptions, ListTransformReduce, LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, loadOne, LoadOneCallback, loadOneCallback, LoadOptions, LoadStep, makeDecodeNodeId, makeDecodeNodeIdRuntime, makeGrafastSchema, mapsMatch, Maybe, Modifier, Multistep, multistep, newGrafastFieldConfigBuilder, newInputObjectTypeBuilder, newObjectTypeBuilder, node, NodeIdCodec, nodeIdFromNode, NodeIdHandler, NodeStep, noop, object, ObjectFieldConfig, objectFieldSpec, ObjectLikeStep, ObjectPlan, ObjectPlanMeta, objectSpec, ObjectStep, ObjectTypeFields, ObjectTypeSpec, OperationPlan, operationPlan, PageInfoCapableStep, partitionByIndex, PlanTypeInfo, PromiseOrDirect, proxy, ProxyStep, recordsMatch, remapKeys, RemapKeysStep, reverse, reverseArray, ReverseStep, rootValue, SafeError, ScalarPlan, ScalarPlanResolver, setsMatch, Setter, setter, SetterCapable, sideEffect, SideEffectStep, specFromNodeId, Step, stepADependsOnStepB, stepAMayDependOnStepB, stepAShouldTryAndInlineIntoStepB, StepOptimizeOptions, stepsAreInSamePhase, StepStreamOptions, stringifyPayload, stripAnsi, subscribe, trap, TRAP_ERROR, TRAP_ERROR_OR_INHIBITED, TRAP_INHIBITED, TypedEventEmitter, UnaryExecutionValue, UnbatchedStep as UnbatchedExecutableStep, UnbatchedExecutionExtra, UnbatchedStep, UnionPlan, UnwrapMultistep, };
|
|
33
35
|
export { hookArgs } from "./args.js";
|
|
34
36
|
export { version } from "./version.js";
|
|
35
37
|
/** @deprecated Renamed to 'applyTransforms' */
|
|
@@ -81,6 +83,51 @@ declare global {
|
|
|
81
83
|
assertStep?: ((step: Step) => asserts step is Step) | {
|
|
82
84
|
new (...args: any[]): Step;
|
|
83
85
|
} | null;
|
|
86
|
+
/**
|
|
87
|
+
* Plantime. Given `$stepOrSpecifier`, a step that _hopefully_ represents
|
|
88
|
+
* relevant data for this object type, return a step that can be used for
|
|
89
|
+
* planning this object type. Used in the default implementation of
|
|
90
|
+
* `AbstractTypePlanner.planForType` if that method is not provided.
|
|
91
|
+
*/
|
|
92
|
+
planType?($stepOrSpecifier: Step): Step;
|
|
93
|
+
}
|
|
94
|
+
interface InterfaceTypeExtensions {
|
|
95
|
+
/**
|
|
96
|
+
* Takes a step representing this polymorphic position, and returns a
|
|
97
|
+
* "specifier" step that will be input to planType. If not specified, the
|
|
98
|
+
* step's own `.toSpecifier()` will be used, if present, otherwise the
|
|
99
|
+
* step's own `.toRecord()`, and failing that the step itself.
|
|
100
|
+
*/
|
|
101
|
+
toSpecifier?($step: Step): Step;
|
|
102
|
+
/**
|
|
103
|
+
* Plantime. `$stepOrSpecifier` is either a step returned from a field or
|
|
104
|
+
* list position with an abstract type, or a `__ValueStep` that
|
|
105
|
+
* represents the combined values of such steps (to prevent unbounded
|
|
106
|
+
* plan branching). `planType` must then construct a step that
|
|
107
|
+
* represents the `__typename` related to this given specifier (or `null`
|
|
108
|
+
* if no match can be found) and a `planForType` method which, when
|
|
109
|
+
* called, should return the step for the given type.
|
|
110
|
+
*/
|
|
111
|
+
planType?($stepOrSpecifier: Step, info: PlanTypeInfo): AbstractTypePlanner;
|
|
112
|
+
}
|
|
113
|
+
interface UnionTypeExtensions {
|
|
114
|
+
/**
|
|
115
|
+
* Takes a step representing this polymorphic position, and returns a
|
|
116
|
+
* "specifier" step that will be input to planType. If not specified, the
|
|
117
|
+
* step's own `.toSpecifier()` will be used, if present, otherwise the
|
|
118
|
+
* step's own `.toRecord()`, and failing that the step itself.
|
|
119
|
+
*/
|
|
120
|
+
toSpecifier?($step: Step): Step;
|
|
121
|
+
/**
|
|
122
|
+
* Plantime. `$stepOrSpecifier` is either a step returned from a field or
|
|
123
|
+
* list position with an abstract type, or a `__ValueStep` that
|
|
124
|
+
* represents the combined values of such steps (to prevent unbounded
|
|
125
|
+
* plan branching). `planType` must then construct a step that
|
|
126
|
+
* represents the `__typename` related to this given specifier (or `null`
|
|
127
|
+
* if no match can be found) and a `planForType` method which, when
|
|
128
|
+
* called, should return the step for the given type.
|
|
129
|
+
*/
|
|
130
|
+
planType?($stepOrSpecifier: Step, info: PlanTypeInfo): AbstractTypePlanner;
|
|
84
131
|
}
|
|
85
132
|
interface EnumTypeExtensions {
|
|
86
133
|
}
|
|
@@ -142,6 +189,21 @@ declare global {
|
|
|
142
189
|
*/
|
|
143
190
|
explain?: boolean | string[];
|
|
144
191
|
timeouts?: GrafastTimeouts;
|
|
192
|
+
/**
|
|
193
|
+
* How many planning layers deep do we allow? Should be handled by validation.
|
|
194
|
+
*
|
|
195
|
+
* A planning layer can happen due to:
|
|
196
|
+
*
|
|
197
|
+
* - A nested selection set
|
|
198
|
+
* - Planning a field return type
|
|
199
|
+
* - A list position
|
|
200
|
+
* - A polymorphic type
|
|
201
|
+
* - A deferred/streamed response
|
|
202
|
+
*
|
|
203
|
+
* These reasons may each cause 1, 2 or 3 planning layers to be added, so this
|
|
204
|
+
* limit should be set quite high - e.g. 6x the selection set depth.
|
|
205
|
+
*/
|
|
206
|
+
maxPlanningDepth?: number;
|
|
145
207
|
}
|
|
146
208
|
interface Preset {
|
|
147
209
|
/**
|
|
@@ -185,6 +247,12 @@ declare module "graphql" {
|
|
|
185
247
|
interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
|
|
186
248
|
grafast?: Grafast.ObjectTypeExtensions;
|
|
187
249
|
}
|
|
250
|
+
interface GraphQLInterfaceTypeExtensions {
|
|
251
|
+
grafast?: Grafast.InterfaceTypeExtensions;
|
|
252
|
+
}
|
|
253
|
+
interface GraphQLUnionTypeExtensions {
|
|
254
|
+
grafast?: Grafast.UnionTypeExtensions;
|
|
255
|
+
}
|
|
188
256
|
interface GraphQLEnumTypeExtensions {
|
|
189
257
|
grafast?: Grafast.EnumTypeExtensions;
|
|
190
258
|
}
|