grafast 0.1.1-beta.9 → 1.0.0-rc.2
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 -5
- package/dist/args.d.ts +4 -7
- package/dist/args.js +56 -41
- package/dist/assert.js +2 -3
- package/dist/config.d.ts +0 -17
- package/dist/config.js +1 -95
- package/dist/constants.d.ts +79 -0
- package/dist/constants.js +79 -0
- package/dist/constraints.d.ts +15 -1
- package/dist/constraints.js +41 -3
- package/dist/deferred.js +1 -2
- package/dist/dev.js +4 -6
- package/dist/engine/LayerPlan.d.ts +93 -21
- package/dist/engine/LayerPlan.js +531 -297
- package/dist/engine/OperationPlan.d.ts +107 -23
- package/dist/engine/OperationPlan.js +2144 -693
- package/dist/engine/OperationPlanTypes.d.ts +66 -0
- package/dist/engine/OperationPlanTypes.js +3 -0
- package/dist/engine/OutputPlan.d.ts +16 -9
- package/dist/engine/OutputPlan.js +527 -574
- package/dist/engine/StepTracker.js +128 -22
- package/dist/engine/distributor.d.ts +25 -0
- package/dist/engine/distributor.js +342 -0
- package/dist/engine/executeBucket.d.ts +3 -3
- package/dist/engine/executeBucket.js +583 -308
- package/dist/engine/executeOutputPlan.js +1 -2
- package/dist/engine/lib/defaultPlanResolver.d.ts +3 -0
- package/dist/engine/lib/defaultPlanResolver.js +7 -0
- package/dist/engine/lib/withGlobalLayerPlan.d.ts +14 -3
- package/dist/engine/lib/withGlobalLayerPlan.js +65 -6
- package/dist/engine/lock.d.ts +3 -3
- package/dist/engine/lock.js +3 -3
- package/dist/envelop.js +19 -7
- package/dist/error.d.ts +14 -1
- package/dist/error.js +13 -13
- package/dist/establishOperationPlan.d.ts +3 -2
- package/dist/establishOperationPlan.js +66 -48
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +36 -14
- package/dist/exportAs.js +2 -3
- package/dist/global.d.ts +10 -0
- package/dist/global.js +27 -3
- package/dist/grafastGraphql.d.ts +6 -1
- package/dist/grafastGraphql.js +41 -19
- package/dist/grafastPrint.js +43 -12
- package/dist/graphqlCollectFields.d.ts +6 -0
- package/dist/graphqlCollectFields.js +24 -13
- package/dist/graphqlMergeSelectionSets.js +1 -2
- package/dist/incremental.d.ts +13 -0
- package/dist/incremental.js +144 -0
- package/dist/index.d.ts +214 -34
- package/dist/index.js +101 -59
- package/dist/input.js +95 -29
- package/dist/inspect.d.ts +9 -4
- package/dist/inspect.js +4 -3
- package/dist/interfaces.d.ts +275 -178
- package/dist/interfaces.js +0 -79
- package/dist/makeGrafastSchema.d.ts +133 -38
- package/dist/makeGrafastSchema.js +270 -56
- package/dist/mermaid.d.ts +6 -1
- package/dist/mermaid.js +258 -99
- package/dist/middleware.d.ts +7 -0
- package/dist/middleware.js +24 -0
- package/dist/multistep.d.ts +20 -0
- package/dist/multistep.js +55 -0
- package/dist/operationPlan-input.d.ts +5 -4
- package/dist/operationPlan-input.js +165 -367
- package/dist/planJSONInterfaces.d.ts +32 -7
- package/dist/prepare.d.ts +16 -9
- package/dist/prepare.js +168 -115
- package/dist/step.d.ts +152 -110
- package/dist/step.js +338 -208
- package/dist/steps/__cloneStream.d.ts +18 -0
- package/dist/steps/__cloneStream.js +43 -0
- package/dist/steps/__flag.d.ts +19 -16
- package/dist/steps/__flag.js +45 -36
- package/dist/steps/__inputDefault.d.ts +14 -0
- package/dist/steps/__inputDefault.js +48 -0
- package/dist/steps/__inputDynamicScalar.d.ts +2 -4
- package/dist/steps/__inputDynamicScalar.js +4 -2
- package/dist/steps/__inputList.d.ts +5 -9
- package/dist/steps/__inputList.js +4 -1
- package/dist/steps/__inputObject.d.ts +5 -9
- package/dist/steps/__inputObject.js +59 -13
- package/dist/steps/__inputStaticLeaf.d.ts +5 -6
- package/dist/steps/__inputStaticLeaf.js +16 -8
- package/dist/steps/__item.d.ts +10 -10
- package/dist/steps/__item.js +4 -4
- package/dist/steps/__trackedValue.d.ts +13 -44
- package/dist/steps/__trackedValue.js +88 -14
- package/dist/steps/__value.d.ts +9 -4
- package/dist/steps/__value.js +10 -4
- package/dist/steps/_loadCommon.d.ts +28 -0
- package/dist/steps/_loadCommon.js +192 -0
- package/dist/steps/access.d.ts +13 -7
- package/dist/steps/access.js +88 -98
- package/dist/steps/applyInput.d.ts +51 -0
- package/dist/steps/applyInput.js +216 -0
- package/dist/steps/applyTransforms.d.ts +2 -2
- package/dist/steps/applyTransforms.js +17 -13
- package/dist/steps/bakedInput.d.ts +23 -0
- package/dist/steps/bakedInput.js +90 -0
- package/dist/steps/coalesce.d.ts +15 -0
- package/dist/steps/coalesce.js +36 -0
- package/dist/steps/condition.d.ts +5 -5
- package/dist/steps/condition.js +3 -3
- package/dist/steps/connection.d.ts +343 -88
- package/dist/steps/connection.js +866 -193
- package/dist/steps/constant.d.ts +8 -7
- package/dist/steps/constant.js +75 -6
- package/dist/steps/each.d.ts +6 -5
- package/dist/steps/each.js +25 -14
- package/dist/steps/error.d.ts +2 -2
- package/dist/steps/error.js +3 -3
- package/dist/steps/filter.d.ts +3 -2
- package/dist/steps/filter.js +1 -2
- package/dist/steps/first.d.ts +15 -7
- package/dist/steps/first.js +45 -12
- package/dist/steps/get.d.ts +50 -0
- package/dist/steps/get.js +13 -0
- package/dist/steps/graphqlResolver.d.ts +3 -3
- package/dist/steps/graphqlResolver.js +93 -202
- package/dist/steps/groupBy.d.ts +3 -2
- package/dist/steps/groupBy.js +1 -2
- package/dist/steps/index.d.ts +11 -18
- package/dist/steps/index.js +33 -53
- package/dist/steps/lambda.d.ts +8 -8
- package/dist/steps/lambda.js +14 -10
- package/dist/steps/last.d.ts +17 -8
- package/dist/steps/last.js +51 -11
- package/dist/steps/list.d.ts +17 -8
- package/dist/steps/list.js +47 -6
- package/dist/steps/listTransform.d.ts +19 -17
- package/dist/steps/listTransform.js +18 -13
- package/dist/steps/listen.d.ts +7 -8
- package/dist/steps/listen.js +64 -11
- package/dist/steps/loadMany.d.ts +98 -0
- package/dist/steps/loadMany.js +173 -0
- package/dist/steps/loadOne.d.ts +85 -0
- package/dist/steps/loadOne.js +150 -0
- package/dist/steps/loadedRecord.d.ts +31 -0
- package/dist/steps/loadedRecord.js +87 -0
- package/dist/steps/node.d.ts +20 -34
- package/dist/steps/node.js +37 -77
- package/dist/steps/object.d.ts +23 -15
- package/dist/steps/object.js +182 -53
- package/dist/steps/partitionByIndex.d.ts +3 -2
- package/dist/steps/partitionByIndex.js +1 -2
- package/dist/steps/proxy.d.ts +7 -13
- package/dist/steps/proxy.js +6 -6
- package/dist/steps/remapKeys.d.ts +7 -7
- package/dist/steps/remapKeys.js +15 -18
- package/dist/steps/reverse.d.ts +5 -5
- package/dist/steps/reverse.js +5 -5
- package/dist/steps/setter.d.ts +9 -18
- package/dist/steps/setter.js +24 -14
- package/dist/steps/sideEffect.d.ts +7 -8
- package/dist/steps/sideEffect.js +14 -9
- package/dist/stringifyPayload.js +1 -2
- package/dist/stripAnsi.js +2 -2
- package/dist/subscribe.js +24 -5
- package/dist/tamedevilUtils.d.ts +15 -0
- package/dist/tamedevilUtils.js +82 -0
- package/dist/thereCanBeOnlyOne.js +1 -1
- package/dist/timeSource.d.ts +0 -1
- package/dist/unbatchedStepExecute.d.ts +6 -0
- package/dist/unbatchedStepExecute.js +100 -0
- package/dist/utils.d.ts +94 -31
- package/dist/utils.js +489 -76
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -12
- package/dist/polymorphic.d.ts +0 -14
- package/dist/polymorphic.js +0 -73
- package/dist/steps/load.d.ts +0 -92
- package/dist/steps/load.js +0 -337
- package/dist/steps/polymorphicBranch.d.ts +0 -27
- package/dist/steps/polymorphicBranch.js +0 -62
package/README.md
CHANGED
|
@@ -50,12 +50,7 @@ And please give some love to our featured sponsors 🤩:
|
|
|
50
50
|
|
|
51
51
|
<table><tr>
|
|
52
52
|
<td align="center"><a href="https://www.the-guild.dev/"><img src="https://graphile.org/images/sponsors/theguild.png" width="90" height="90" alt="The Guild" /><br />The Guild</a> *</td>
|
|
53
|
-
<td align="center"><a href="https://dovetailapp.com/"><img src="https://graphile.org/images/sponsors/dovetail.png" width="90" height="90" alt="Dovetail" /><br />Dovetail</a> *</td>
|
|
54
|
-
<td align="center"><a href="https://www.netflix.com/"><img src="https://graphile.org/images/sponsors/Netflix.png" width="90" height="90" alt="Netflix" /><br />Netflix</a> *</td>
|
|
55
|
-
<td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td>
|
|
56
|
-
</tr><tr>
|
|
57
53
|
<td align="center"><a href="https://gosteelhead.com/"><img src="https://graphile.org/images/sponsors/steelhead.svg" width="90" height="90" alt="Steelhead" /><br />Steelhead</a> *</td>
|
|
58
|
-
<td align="center"><a href="https://www.sylvera.com/"><img src="https://graphile.org/images/sponsors/sylvera.svg" width="90" height="90" alt="Sylvera" /><br />Sylvera</a> *</td>
|
|
59
54
|
</tr></table>
|
|
60
55
|
|
|
61
56
|
<em>\* Sponsors the entire Graphile suite</em>
|
package/dist/args.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { ExecutionArgs } from "graphql";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @experimental
|
|
7
|
-
*/
|
|
8
|
-
export declare function hookArgs(rawArgs: ExecutionArgs, resolvedPreset: GraphileConfig.ResolvedPreset, ctx: Partial<Grafast.RequestContext>): Grafast.ExecutionArgs | PromiseLike<Grafast.ExecutionArgs>;
|
|
2
|
+
import type { GrafastExecutionArgs, PromiseOrDirect } from "./interfaces.js";
|
|
3
|
+
/** @deprecated Pass `resolvedPreset` and `requestContext` via args directly */
|
|
4
|
+
export declare function hookArgs(rawArgs: ExecutionArgs, resolvedPreset: GraphileConfig.ResolvedPreset, ctx: Partial<Grafast.RequestContext>): PromiseOrDirect<Grafast.ExecutionArgs>;
|
|
5
|
+
export declare function hookArgs(rawArgs: GrafastExecutionArgs): PromiseOrDirect<Grafast.ExecutionArgs>;
|
|
9
6
|
//# sourceMappingURL=args.d.ts.map
|
package/dist/args.js
CHANGED
|
@@ -1,62 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hookArgs =
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.hookArgs = hookArgs;
|
|
4
|
+
const constants_js_1 = require("./constants.js");
|
|
5
|
+
const middleware_js_1 = require("./middleware.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
|
+
const EMPTY_OBJECT = Object.freeze(Object.create(null));
|
|
8
|
+
const $$writeTest = Symbol("grafastWriteTest");
|
|
7
9
|
/**
|
|
8
10
|
* Applies Graphile Config hooks to your GraphQL request, e.g. to
|
|
9
11
|
* populate context or similar.
|
|
10
12
|
*
|
|
11
13
|
* @experimental
|
|
12
14
|
*/
|
|
13
|
-
function hookArgs(rawArgs,
|
|
15
|
+
function hookArgs(rawArgs, legacyResolvedPreset, legacyCtx) {
|
|
16
|
+
if (legacyResolvedPreset !== undefined) {
|
|
17
|
+
rawArgs.resolvedPreset = legacyResolvedPreset;
|
|
18
|
+
}
|
|
19
|
+
if (legacyCtx !== undefined) {
|
|
20
|
+
rawArgs.requestContext = rawArgs.requestContext ?? legacyCtx;
|
|
21
|
+
}
|
|
22
|
+
const { middleware: rawMiddleware, resolvedPreset, contextValue: rawContextValue, } = rawArgs;
|
|
23
|
+
try {
|
|
24
|
+
rawContextValue[$$writeTest] = true;
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
// Make context mutable
|
|
28
|
+
rawArgs.contextValue = Object.assign(Object.create(null), rawContextValue);
|
|
29
|
+
}
|
|
30
|
+
const middleware = rawMiddleware === undefined && resolvedPreset != null
|
|
31
|
+
? (0, middleware_js_1.getGrafastMiddleware)(resolvedPreset)
|
|
32
|
+
: (rawMiddleware ?? null);
|
|
33
|
+
if (rawMiddleware === undefined) {
|
|
34
|
+
rawArgs.middleware = middleware;
|
|
35
|
+
}
|
|
14
36
|
const args = rawArgs;
|
|
15
37
|
// Assert that args haven't already been hooked
|
|
16
|
-
if (args[
|
|
38
|
+
if (args[constants_js_1.$$hooked]) {
|
|
17
39
|
throw new Error("Must not call hookArgs twice!");
|
|
18
40
|
}
|
|
19
|
-
args[
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Object.assign(
|
|
41
|
+
args[constants_js_1.$$hooked] = true;
|
|
42
|
+
if (middleware != null) {
|
|
43
|
+
return middleware.run("prepareArgs", { args }, finalizeWithEvent);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return finalize(args);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function finalize(args) {
|
|
50
|
+
const userContext = args.resolvedPreset?.grafast?.context;
|
|
51
|
+
const contextValue = args.contextValue;
|
|
52
|
+
if (typeof userContext === "function") {
|
|
53
|
+
const result = userContext(args.requestContext ?? EMPTY_OBJECT, args);
|
|
54
|
+
if ((0, utils_js_1.isPromiseLike)(result)) {
|
|
55
|
+
// Deliberately shadowed 'result'
|
|
56
|
+
return result.then((result) => {
|
|
57
|
+
Object.assign(contextValue, result);
|
|
36
58
|
return args;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else if (typeof userContext === "object" && userContext !== null) {
|
|
40
|
-
Object.assign(args.contextValue, userContext);
|
|
41
|
-
return args;
|
|
59
|
+
});
|
|
42
60
|
}
|
|
43
61
|
else {
|
|
62
|
+
Object.assign(contextValue, result);
|
|
44
63
|
return args;
|
|
45
64
|
}
|
|
46
|
-
};
|
|
47
|
-
if (resolvedPreset !== config_js_1.NULL_PRESET &&
|
|
48
|
-
resolvedPreset.plugins &&
|
|
49
|
-
resolvedPreset.plugins.length > 0) {
|
|
50
|
-
const event = { args, ctx, resolvedPreset };
|
|
51
|
-
const result = (0, config_js_1.hook)(resolvedPreset, "args", event);
|
|
52
|
-
if ((0, utils_js_1.isPromiseLike)(result)) {
|
|
53
|
-
return result.then(() => finalize(event.args));
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
return finalize(event.args);
|
|
57
|
-
}
|
|
58
65
|
}
|
|
59
|
-
|
|
66
|
+
else if (typeof userContext === "object" && userContext !== null) {
|
|
67
|
+
Object.assign(contextValue, userContext);
|
|
68
|
+
return args;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return args;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function finalizeWithEvent(event) {
|
|
75
|
+
return finalize(event.args);
|
|
60
76
|
}
|
|
61
|
-
exports.hookArgs = hookArgs;
|
|
62
77
|
//# sourceMappingURL=args.js.map
|
package/dist/assert.js
CHANGED
|
@@ -6,19 +6,18 @@
|
|
|
6
6
|
* https://github.com/facebook/jest/issues/2549
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.ok = ok;
|
|
10
|
+
exports.strictEqual = strictEqual;
|
|
10
11
|
/** Equivalent to `assert.ok(...)` */
|
|
11
12
|
function ok(val, message) {
|
|
12
13
|
if (!val) {
|
|
13
14
|
throw new Error(message);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
exports.ok = ok;
|
|
17
17
|
/** Equivalent to `assert.strictEqual(...)` */
|
|
18
18
|
function strictEqual(actual, expected, message) {
|
|
19
19
|
if (actual !== expected) {
|
|
20
20
|
throw new Error(message + ` (${actual} !== ${expected})`);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
exports.strictEqual = strictEqual;
|
|
24
23
|
//# sourceMappingURL=assert.js.map
|
package/dist/config.d.ts
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
import type { AsyncHooks, PluginHook } from "graphile-config";
|
|
2
1
|
export declare const NULL_PRESET: GraphileConfig.ResolvedPreset;
|
|
3
|
-
type GraphileConfigModule = typeof import("graphile-config");
|
|
4
|
-
type PromiseOrValue<T> = T | Promise<T>;
|
|
5
|
-
export declare function withGraphileConfig<T>(callback: (graphileConfig: GraphileConfigModule | null) => PromiseOrValue<T>): PromiseOrValue<T>;
|
|
6
|
-
declare const $$skipHooks: unique symbol;
|
|
7
|
-
declare const $$hooksForPreset: unique symbol;
|
|
8
|
-
declare global {
|
|
9
|
-
namespace GraphileConfig {
|
|
10
|
-
interface ResolvedPreset {
|
|
11
|
-
[$$hooksForPreset]?: null | AsyncHooks<GraphileConfig.GrafastHooks>;
|
|
12
|
-
[$$skipHooks]?: Record<string, boolean>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export declare function withHooks<TResult>(resolvedPreset: GraphileConfig.ResolvedPreset, callback: (hooks: AsyncHooks<GraphileConfig.GrafastHooks> | null) => PromiseOrValue<TResult>): PromiseOrValue<TResult>;
|
|
17
|
-
export declare function hook<THookName extends keyof GraphileConfig.GrafastHooks>(resolvedPreset: GraphileConfig.ResolvedPreset, hookName: THookName, ...args: Parameters<GraphileConfig.GrafastHooks[THookName] extends PluginHook<infer U> ? U : never>): PromiseOrValue<void>;
|
|
18
|
-
export {};
|
|
19
2
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.js
CHANGED
|
@@ -1,99 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NULL_PRESET = void 0;
|
|
4
4
|
exports.NULL_PRESET = Object.freeze(Object.create(null));
|
|
5
|
-
let graphileConfig = undefined;
|
|
6
|
-
let graphileConfigLoaded = false;
|
|
7
|
-
function withGraphileConfig(callback) {
|
|
8
|
-
if (graphileConfig === undefined) {
|
|
9
|
-
// ESM:
|
|
10
|
-
// This should be
|
|
11
|
-
// graphileConfig = import("graphile-config").then(
|
|
12
|
-
// but that causes a segfault in jest/node when testing third party
|
|
13
|
-
// modules. So we had to convert everything to CommonJS.
|
|
14
|
-
graphileConfig = new Promise((resolve, reject) => {
|
|
15
|
-
try {
|
|
16
|
-
resolve(require("graphile-config"));
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
if (e.code === "ERR_REQUIRE_ESM") {
|
|
20
|
-
return import("graphile-config").then(resolve, reject);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
reject(e);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}).then((GC) => {
|
|
27
|
-
graphileConfig = GC;
|
|
28
|
-
graphileConfigLoaded = true;
|
|
29
|
-
return GC;
|
|
30
|
-
}, () => {
|
|
31
|
-
graphileConfig = null;
|
|
32
|
-
graphileConfigLoaded = true;
|
|
33
|
-
return null;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
if (graphileConfigLoaded) {
|
|
37
|
-
return callback(graphileConfig);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return graphileConfig.then(callback);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.withGraphileConfig = withGraphileConfig;
|
|
44
|
-
const $$skipHooks = Symbol("skipHooks");
|
|
45
|
-
const $$hooksForPreset = Symbol("grafastHooks");
|
|
46
|
-
function withHooks(resolvedPreset, callback) {
|
|
47
|
-
const existing = resolvedPreset[$$hooksForPreset];
|
|
48
|
-
if (existing !== undefined) {
|
|
49
|
-
return callback(existing);
|
|
50
|
-
}
|
|
51
|
-
if (!resolvedPreset.plugins || resolvedPreset.plugins.length === 0) {
|
|
52
|
-
resolvedPreset[$$hooksForPreset] = null;
|
|
53
|
-
return callback(null);
|
|
54
|
-
}
|
|
55
|
-
const plugins = resolvedPreset.plugins;
|
|
56
|
-
return withGraphileConfig((gc) => {
|
|
57
|
-
if (gc !== null) {
|
|
58
|
-
const hooks = new gc.AsyncHooks();
|
|
59
|
-
gc.applyHooks(plugins, (p) => p.grafast?.hooks, (name, fn, _plugin) => {
|
|
60
|
-
hooks.hook(name, fn);
|
|
61
|
-
});
|
|
62
|
-
resolvedPreset[$$hooksForPreset] = hooks;
|
|
63
|
-
return callback(hooks);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
resolvedPreset[$$hooksForPreset] = null;
|
|
67
|
-
return callback(null);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
exports.withHooks = withHooks;
|
|
72
|
-
function hook(resolvedPreset, hookName, ...args) {
|
|
73
|
-
if (resolvedPreset[$$skipHooks]?.[hookName]) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
return withHooks(resolvedPreset, (hooks) => {
|
|
77
|
-
if (hooks !== null) {
|
|
78
|
-
if (hooks.callbacks[hookName] !== undefined) {
|
|
79
|
-
return hooks.process(hookName, ...args);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (!resolvedPreset[$$skipHooks]) {
|
|
83
|
-
resolvedPreset[$$skipHooks] = Object.create(null);
|
|
84
|
-
}
|
|
85
|
-
resolvedPreset[$$skipHooks][hookName] = true;
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
if (!resolvedPreset[$$skipHooks]) {
|
|
91
|
-
resolvedPreset[$$skipHooks] = Object.create(null);
|
|
92
|
-
}
|
|
93
|
-
resolvedPreset[$$skipHooks][hookName] = true;
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
exports.hook = hook;
|
|
99
5
|
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare const $$hooked: unique symbol;
|
|
2
|
+
export declare const $$grafastContext: unique symbol;
|
|
3
|
+
export declare const $$planResults: unique symbol;
|
|
4
|
+
export declare const $$id: unique symbol;
|
|
5
|
+
/** Return the value verbatim, don't execute */
|
|
6
|
+
export declare const $$verbatim: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* If we're sure the data is the right shape and valid, we can set this key and
|
|
9
|
+
* it can be returned directly
|
|
10
|
+
*/
|
|
11
|
+
export declare const $$bypassGraphQL: unique symbol;
|
|
12
|
+
export declare const $$data: unique symbol;
|
|
13
|
+
/**
|
|
14
|
+
* For attaching additional metadata to the GraphQL execution result, for
|
|
15
|
+
* example details of the plan or SQL queries or similar that were executed.
|
|
16
|
+
*/
|
|
17
|
+
export declare const $$extensions: unique symbol;
|
|
18
|
+
/**
|
|
19
|
+
* Set this key on a type if that type's serialization is idempotent (that is
|
|
20
|
+
* to say `serialize(serialize(thing)) === serialize(thing)`). This means we
|
|
21
|
+
* don't have to "roll-back" serialization if we need to fallback to graphql-js
|
|
22
|
+
* execution.
|
|
23
|
+
*/
|
|
24
|
+
export declare const $$idempotent: unique symbol;
|
|
25
|
+
/**
|
|
26
|
+
* The event emitter used for outputting execution events.
|
|
27
|
+
*/
|
|
28
|
+
export declare const $$eventEmitter: unique symbol;
|
|
29
|
+
/**
|
|
30
|
+
* Used to indicate that an array has more results available via a stream.
|
|
31
|
+
*/
|
|
32
|
+
export declare const $$streamMore: unique symbol;
|
|
33
|
+
export declare const $$proxy: unique symbol;
|
|
34
|
+
/**
|
|
35
|
+
* If an error has this property set then it's safe to send through to the user
|
|
36
|
+
* without being masked.
|
|
37
|
+
*/
|
|
38
|
+
export declare const $$safeError: unique symbol;
|
|
39
|
+
/** The layerPlan used as a subroutine for this step */
|
|
40
|
+
export declare const $$subroutine: unique symbol;
|
|
41
|
+
/** For tracking the timeout a TimeoutError happened from */
|
|
42
|
+
export declare const $$timeout: unique symbol;
|
|
43
|
+
/** For tracking _when_ the timeout happened (because once the JIT has warmed it might not need so long) */
|
|
44
|
+
export declare const $$ts: unique symbol;
|
|
45
|
+
export declare const $$queryCache: unique symbol;
|
|
46
|
+
/**
|
|
47
|
+
* We store the cache directly onto the GraphQLSchema so that it gets garbage
|
|
48
|
+
* collected along with the schema when it's not needed any more. To do so, we
|
|
49
|
+
* attach it using this symbol.
|
|
50
|
+
*/
|
|
51
|
+
export declare const $$cacheByOperation: unique symbol;
|
|
52
|
+
export declare const $$contextPlanCache: unique symbol;
|
|
53
|
+
/**
|
|
54
|
+
* A bitwise number representing a number of flags:
|
|
55
|
+
*
|
|
56
|
+
* - 0: normal execution value
|
|
57
|
+
* - 1: errored (trappable)
|
|
58
|
+
* - 2: null (trappable)
|
|
59
|
+
* - 4: inhibited (trappable)
|
|
60
|
+
* - 8: disabled due to polymorphism (untrappable)
|
|
61
|
+
* - 16: stopped (untrappable) - e.g. due to fatal (unrecoverable) error
|
|
62
|
+
* - 32: ...
|
|
63
|
+
*/
|
|
64
|
+
export type ExecutionEntryFlags = number & {
|
|
65
|
+
readonly tsBrand?: unique symbol;
|
|
66
|
+
};
|
|
67
|
+
export declare const NO_FLAGS: ExecutionEntryFlags;
|
|
68
|
+
export declare const FLAG_ERROR: ExecutionEntryFlags;
|
|
69
|
+
export declare const FLAG_NULL: ExecutionEntryFlags;
|
|
70
|
+
export declare const FLAG_INHIBITED: ExecutionEntryFlags;
|
|
71
|
+
export declare const FLAG_POLY_SKIPPED: ExecutionEntryFlags;
|
|
72
|
+
export declare const FLAG_STOPPED: ExecutionEntryFlags;
|
|
73
|
+
export declare const ALL_FLAGS: ExecutionEntryFlags;
|
|
74
|
+
/** By default, accept null values as an input */
|
|
75
|
+
export declare const DEFAULT_ACCEPT_FLAGS: ExecutionEntryFlags;
|
|
76
|
+
export declare const TRAPPABLE_FLAGS: ExecutionEntryFlags;
|
|
77
|
+
export declare const DEFAULT_FORBIDDEN_FLAGS: ExecutionEntryFlags;
|
|
78
|
+
export declare const FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS: ExecutionEntryFlags;
|
|
79
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS = exports.DEFAULT_FORBIDDEN_FLAGS = exports.TRAPPABLE_FLAGS = exports.DEFAULT_ACCEPT_FLAGS = exports.ALL_FLAGS = exports.FLAG_STOPPED = exports.FLAG_POLY_SKIPPED = exports.FLAG_INHIBITED = exports.FLAG_NULL = exports.FLAG_ERROR = exports.NO_FLAGS = exports.$$contextPlanCache = exports.$$cacheByOperation = exports.$$queryCache = exports.$$deepDepSkip = exports.$$ts = exports.$$timeout = exports.$$subroutine = exports.$$safeError = exports.$$proxy = exports.$$streamMore = exports.$$eventEmitter = exports.$$idempotent = exports.$$extensions = exports.$$data = exports.$$bypassGraphQL = exports.$$verbatim = exports.$$id = exports.$$planResults = exports.$$grafastContext = exports.$$hooked = void 0;
|
|
4
|
+
exports.$$hooked = Symbol("hookArgsApplied");
|
|
5
|
+
exports.$$grafastContext = Symbol("context");
|
|
6
|
+
exports.$$planResults = Symbol("planResults");
|
|
7
|
+
exports.$$id = Symbol("id");
|
|
8
|
+
/** Return the value verbatim, don't execute */
|
|
9
|
+
exports.$$verbatim = Symbol("verbatim");
|
|
10
|
+
/**
|
|
11
|
+
* If we're sure the data is the right shape and valid, we can set this key and
|
|
12
|
+
* it can be returned directly
|
|
13
|
+
*/
|
|
14
|
+
exports.$$bypassGraphQL = Symbol("bypassGraphQL");
|
|
15
|
+
exports.$$data = Symbol("data");
|
|
16
|
+
/**
|
|
17
|
+
* For attaching additional metadata to the GraphQL execution result, for
|
|
18
|
+
* example details of the plan or SQL queries or similar that were executed.
|
|
19
|
+
*/
|
|
20
|
+
exports.$$extensions = Symbol("extensions");
|
|
21
|
+
/**
|
|
22
|
+
* Set this key on a type if that type's serialization is idempotent (that is
|
|
23
|
+
* to say `serialize(serialize(thing)) === serialize(thing)`). This means we
|
|
24
|
+
* don't have to "roll-back" serialization if we need to fallback to graphql-js
|
|
25
|
+
* execution.
|
|
26
|
+
*/
|
|
27
|
+
exports.$$idempotent = Symbol("idempotent");
|
|
28
|
+
/**
|
|
29
|
+
* The event emitter used for outputting execution events.
|
|
30
|
+
*/
|
|
31
|
+
exports.$$eventEmitter = Symbol("executionEventEmitter");
|
|
32
|
+
/**
|
|
33
|
+
* Used to indicate that an array has more results available via a stream.
|
|
34
|
+
*/
|
|
35
|
+
exports.$$streamMore = Symbol("streamMore");
|
|
36
|
+
exports.$$proxy = Symbol("proxy");
|
|
37
|
+
/**
|
|
38
|
+
* If an error has this property set then it's safe to send through to the user
|
|
39
|
+
* without being masked.
|
|
40
|
+
*/
|
|
41
|
+
exports.$$safeError = Symbol("safeError");
|
|
42
|
+
/** The layerPlan used as a subroutine for this step */
|
|
43
|
+
exports.$$subroutine = Symbol("subroutine");
|
|
44
|
+
/** For tracking the timeout a TimeoutError happened from */
|
|
45
|
+
exports.$$timeout = Symbol("timeout");
|
|
46
|
+
/** For tracking _when_ the timeout happened (because once the JIT has warmed it might not need so long) */
|
|
47
|
+
exports.$$ts = Symbol("timestamp");
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
exports.$$deepDepSkip = Symbol("deepDepSkip_experimental");
|
|
52
|
+
exports.$$queryCache = Symbol("queryCache");
|
|
53
|
+
/**
|
|
54
|
+
* We store the cache directly onto the GraphQLSchema so that it gets garbage
|
|
55
|
+
* collected along with the schema when it's not needed any more. To do so, we
|
|
56
|
+
* attach it using this symbol.
|
|
57
|
+
*/
|
|
58
|
+
exports.$$cacheByOperation = Symbol("cacheByOperation");
|
|
59
|
+
exports.$$contextPlanCache = Symbol("contextPlanCache");
|
|
60
|
+
function flag(f) {
|
|
61
|
+
return f;
|
|
62
|
+
}
|
|
63
|
+
exports.NO_FLAGS = flag(0); // 0
|
|
64
|
+
exports.FLAG_ERROR = flag(1 << 0); // 1
|
|
65
|
+
exports.FLAG_NULL = flag(1 << 1); // 2
|
|
66
|
+
exports.FLAG_INHIBITED = flag(1 << 2); // 4
|
|
67
|
+
exports.FLAG_POLY_SKIPPED = flag(1 << 3); // 8
|
|
68
|
+
exports.FLAG_STOPPED = flag(1 << 4); // 16
|
|
69
|
+
exports.ALL_FLAGS = flag(exports.FLAG_ERROR | exports.FLAG_NULL | exports.FLAG_INHIBITED | exports.FLAG_POLY_SKIPPED | exports.FLAG_STOPPED);
|
|
70
|
+
/** By default, accept null values as an input */
|
|
71
|
+
exports.DEFAULT_ACCEPT_FLAGS = flag(exports.FLAG_NULL);
|
|
72
|
+
exports.TRAPPABLE_FLAGS = flag(exports.FLAG_ERROR | exports.FLAG_NULL | exports.FLAG_INHIBITED);
|
|
73
|
+
exports.DEFAULT_FORBIDDEN_FLAGS = flag(exports.ALL_FLAGS & ~exports.DEFAULT_ACCEPT_FLAGS);
|
|
74
|
+
exports.FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS = flag(exports.FLAG_NULL | exports.FLAG_POLY_SKIPPED);
|
|
75
|
+
// TODO: make `FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS = flag(FLAG_ERROR | FLAG_NULL | FLAG_POLY_SKIPPED | FLAG_INHIBITED | FLAG_STOPPED);`
|
|
76
|
+
// Currently this isn't enabled because the bucket has to exist for the output
|
|
77
|
+
// plan to throw the error; really the root should be evaluated before
|
|
78
|
+
// descending into the output plan rather than as part of descending?
|
|
79
|
+
//# sourceMappingURL=constants.js.map
|
package/dist/constraints.d.ts
CHANGED
|
@@ -27,6 +27,20 @@ interface ExistsConstraint {
|
|
|
27
27
|
path: (string | number)[];
|
|
28
28
|
exists: boolean;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* If `keys` is null: asserts that there is no value at the given
|
|
32
|
+
* path.
|
|
33
|
+
*
|
|
34
|
+
* Otherwise: asserts that the value at the given path has the exact same keys.
|
|
35
|
+
*/
|
|
36
|
+
interface KeysConstraint {
|
|
37
|
+
type: "keys";
|
|
38
|
+
path: (string | number)[];
|
|
39
|
+
/**
|
|
40
|
+
* If this is null it implies that the object did not exist.
|
|
41
|
+
*/
|
|
42
|
+
keys: ReadonlyArray<string> | null;
|
|
43
|
+
}
|
|
30
44
|
/**
|
|
31
45
|
* If `expectedLength` is null: asserts that there is no value at the given
|
|
32
46
|
* path.
|
|
@@ -52,7 +66,7 @@ interface IsEmptyConstraint {
|
|
|
52
66
|
path: (string | number)[];
|
|
53
67
|
isEmpty: boolean;
|
|
54
68
|
}
|
|
55
|
-
export type Constraint = ValueConstraint | EqualityConstraint | ExistsConstraint | LengthConstraint | IsEmptyConstraint;
|
|
69
|
+
export type Constraint = ValueConstraint | EqualityConstraint | ExistsConstraint | LengthConstraint | IsEmptyConstraint | KeysConstraint;
|
|
56
70
|
/**
|
|
57
71
|
* Implements the `MatchesConstraints` algorithm.
|
|
58
72
|
*/
|
package/dist/constraints.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// and then compiling (JIT-style) remaining constraints into a function using
|
|
4
4
|
// tamedevil
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.matchesConstraints =
|
|
6
|
+
exports.matchesConstraints = matchesConstraints;
|
|
7
7
|
function valueAtPath(object, path) {
|
|
8
8
|
let value = object;
|
|
9
9
|
for (let i = 0, l = path.length; i < l; i++) {
|
|
@@ -32,7 +32,8 @@ function matchesConstraint(constraint, object) {
|
|
|
32
32
|
const value = valueAtPath(object, constraint.path);
|
|
33
33
|
switch (constraint.type) {
|
|
34
34
|
case "length": {
|
|
35
|
-
|
|
35
|
+
const actualLength = Array.isArray(value) ? value.length : null;
|
|
36
|
+
return actualLength === constraint.expectedLength;
|
|
36
37
|
}
|
|
37
38
|
case "exists": {
|
|
38
39
|
return (value !== undefined) === constraint.exists;
|
|
@@ -49,6 +50,44 @@ function matchesConstraint(constraint, object) {
|
|
|
49
50
|
Object.keys(value).length === 0;
|
|
50
51
|
return isEmpty === constraint.isEmpty;
|
|
51
52
|
}
|
|
53
|
+
case "keys": {
|
|
54
|
+
const { keys: expectedKeys } = constraint;
|
|
55
|
+
if (expectedKeys === null) {
|
|
56
|
+
return value == null || typeof value !== "object";
|
|
57
|
+
}
|
|
58
|
+
else if (value == null || typeof value !== "object") {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// keys are always in order of the gql type; see coerceInputValue and __InputObjectStep ctor
|
|
63
|
+
const valueKeys = Object.keys(value);
|
|
64
|
+
const valueKeyCount = valueKeys.length;
|
|
65
|
+
const expectedKeyCount = expectedKeys.length;
|
|
66
|
+
// Optimization: early bail
|
|
67
|
+
if (valueKeyCount < expectedKeyCount) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* This is `i` but adjusted so that `undefined` doesn't increment it.
|
|
72
|
+
* Should match index in `expectedKeys`.
|
|
73
|
+
*/
|
|
74
|
+
let definedRawKeyCount = 0;
|
|
75
|
+
for (let i = 0; i < valueKeyCount; i++) {
|
|
76
|
+
const valueKey = valueKeys[i];
|
|
77
|
+
if (value[valueKey] !== undefined) {
|
|
78
|
+
if (valueKey !== expectedKeys[definedRawKeyCount]) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
definedRawKeyCount++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Make sure there aren't any additional expected keys
|
|
85
|
+
if (definedRawKeyCount !== expectedKeyCount) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
52
91
|
default: {
|
|
53
92
|
const never = constraint;
|
|
54
93
|
throw new Error(`Unsupported constraint type '${never.type}'`);
|
|
@@ -68,5 +107,4 @@ function matchesConstraints(constraints, object) {
|
|
|
68
107
|
}
|
|
69
108
|
return true;
|
|
70
109
|
}
|
|
71
|
-
exports.matchesConstraints = matchesConstraints;
|
|
72
110
|
//# sourceMappingURL=constraints.js.map
|
package/dist/deferred.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defer =
|
|
3
|
+
exports.defer = defer;
|
|
4
4
|
function NOOP() { }
|
|
5
5
|
/**
|
|
6
6
|
* Returns a promise that can be `.resolve()`-ed or `.reject()`-ed at a later
|
|
@@ -21,5 +21,4 @@ function defer() {
|
|
|
21
21
|
promise.then(null, NOOP);
|
|
22
22
|
return promise;
|
|
23
23
|
}
|
|
24
|
-
exports.defer = defer;
|
|
25
24
|
//# sourceMappingURL=deferred.js.map
|
package/dist/dev.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isTest = exports.isDev = void 0;
|
|
4
|
+
exports.noop = noop;
|
|
4
5
|
/**
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
@@ -13,15 +14,12 @@ const mode = graphileEnv !== undefined ? graphileEnv : nodeEnv;
|
|
|
13
14
|
exports.isDev = mode === "development" || mode === "test";
|
|
14
15
|
exports.isTest = mode === "test";
|
|
15
16
|
function noop() { }
|
|
16
|
-
exports.noop = noop;
|
|
17
17
|
if (typeof process !== "undefined" &&
|
|
18
18
|
typeof graphileEnv === "undefined" &&
|
|
19
19
|
typeof nodeEnv === "undefined") {
|
|
20
20
|
console.warn(`The GRAPHILE_ENV environmental variable is not set; Grafast will run in production mode. In your development environments, it's recommended that you set \`GRAPHILE_ENV=development\` to opt in to additional checks that will provide guidance and help you to catch issues in your code earlier, and other changes such as formatting to improve your development experience.`);
|
|
21
21
|
}
|
|
22
|
-
else if (exports.isDev && !exports.isTest) {
|
|
23
|
-
console.warn(`Grafast is running in development mode due to
|
|
24
|
-
? `GRAPHILE_ENV=${graphileEnv}`
|
|
25
|
-
: `NODE_ENV=${nodeEnv}`}\`; this is recommended for development environments (and strongly discouraged in production), but will impact on performance - in particular, planning will be significantly more expensive.`);
|
|
22
|
+
else if (exports.isDev && !exports.isTest && typeof graphileEnv === "undefined") {
|
|
23
|
+
console.warn(`Grafast is running in development mode due to \`NODE_ENV=${nodeEnv}\`; this is recommended for development environments (and strongly discouraged in production), but will impact on performance - in particular, planning will be significantly more expensive. To remove this warning, make this explicit with \`GRAPHILE_ENV=development\` envvar.`);
|
|
26
24
|
}
|
|
27
25
|
//# sourceMappingURL=dev.js.map
|