grafast 0.1.1-beta.20 → 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.
Files changed (133) hide show
  1. package/dist/args.js +2 -3
  2. package/dist/assert.js +2 -3
  3. package/dist/constraints.js +1 -2
  4. package/dist/deferred.js +1 -2
  5. package/dist/dev.js +2 -2
  6. package/dist/engine/LayerPlan.d.ts +20 -16
  7. package/dist/engine/LayerPlan.js +5 -10
  8. package/dist/engine/OperationPlan.d.ts +12 -13
  9. package/dist/engine/OperationPlan.js +210 -146
  10. package/dist/engine/OutputPlan.d.ts +4 -4
  11. package/dist/engine/OutputPlan.js +13 -10
  12. package/dist/engine/StepTracker.js +11 -2
  13. package/dist/engine/executeBucket.js +135 -94
  14. package/dist/engine/executeOutputPlan.js +1 -2
  15. package/dist/engine/lib/defaultPlanResolver.d.ts +6 -0
  16. package/dist/engine/lib/defaultPlanResolver.js +11 -0
  17. package/dist/engine/lib/withGlobalLayerPlan.d.ts +2 -2
  18. package/dist/engine/lib/withGlobalLayerPlan.js +4 -5
  19. package/dist/engine/lock.d.ts +3 -3
  20. package/dist/engine/lock.js +3 -3
  21. package/dist/error.js +4 -4
  22. package/dist/establishOperationPlan.js +2 -3
  23. package/dist/execute.js +3 -4
  24. package/dist/exportAs.js +2 -3
  25. package/dist/global.js +2 -3
  26. package/dist/grafastGraphql.js +2 -3
  27. package/dist/grafastPrint.js +7 -8
  28. package/dist/graphqlCollectFields.js +6 -7
  29. package/dist/graphqlMergeSelectionSets.js +1 -2
  30. package/dist/index.d.ts +22 -18
  31. package/dist/index.js +41 -16
  32. package/dist/input.js +75 -28
  33. package/dist/inspect.d.ts +9 -4
  34. package/dist/inspect.js +2 -2
  35. package/dist/interfaces.d.ts +110 -89
  36. package/dist/makeGrafastSchema.d.ts +18 -9
  37. package/dist/makeGrafastSchema.js +64 -30
  38. package/dist/mermaid.js +53 -14
  39. package/dist/middleware.js +1 -2
  40. package/dist/multistep.d.ts +6 -6
  41. package/dist/multistep.js +6 -7
  42. package/dist/operationPlan-input.d.ts +5 -4
  43. package/dist/operationPlan-input.js +131 -399
  44. package/dist/planJSONInterfaces.d.ts +6 -2
  45. package/dist/polymorphic.js +4 -5
  46. package/dist/prepare.js +6 -6
  47. package/dist/step.d.ts +67 -99
  48. package/dist/step.js +99 -127
  49. package/dist/steps/__flag.d.ts +16 -16
  50. package/dist/steps/__flag.js +9 -6
  51. package/dist/steps/__inputDefault.d.ts +14 -0
  52. package/dist/steps/__inputDefault.js +48 -0
  53. package/dist/steps/__inputDynamicScalar.d.ts +2 -4
  54. package/dist/steps/__inputDynamicScalar.js +4 -2
  55. package/dist/steps/__inputList.d.ts +5 -9
  56. package/dist/steps/__inputList.js +4 -1
  57. package/dist/steps/__inputObject.d.ts +6 -11
  58. package/dist/steps/__inputObject.js +13 -3
  59. package/dist/steps/__inputStaticLeaf.d.ts +2 -4
  60. package/dist/steps/__inputStaticLeaf.js +3 -1
  61. package/dist/steps/__item.d.ts +6 -6
  62. package/dist/steps/__item.js +1 -1
  63. package/dist/steps/__trackedValue.d.ts +4 -49
  64. package/dist/steps/__trackedValue.js +24 -6
  65. package/dist/steps/__value.d.ts +3 -3
  66. package/dist/steps/__value.js +3 -2
  67. package/dist/steps/access.d.ts +7 -6
  68. package/dist/steps/access.js +14 -7
  69. package/dist/steps/applyInput.d.ts +44 -0
  70. package/dist/steps/applyInput.js +206 -0
  71. package/dist/steps/applyTransforms.d.ts +2 -2
  72. package/dist/steps/applyTransforms.js +7 -5
  73. package/dist/steps/bakedInput.d.ts +23 -0
  74. package/dist/steps/bakedInput.js +90 -0
  75. package/dist/steps/condition.d.ts +5 -5
  76. package/dist/steps/condition.js +3 -3
  77. package/dist/steps/connection.d.ts +42 -39
  78. package/dist/steps/connection.js +51 -35
  79. package/dist/steps/constant.d.ts +4 -8
  80. package/dist/steps/constant.js +54 -6
  81. package/dist/steps/each.d.ts +3 -3
  82. package/dist/steps/each.js +1 -2
  83. package/dist/steps/error.d.ts +2 -2
  84. package/dist/steps/error.js +3 -3
  85. package/dist/steps/filter.d.ts +3 -2
  86. package/dist/steps/filter.js +1 -2
  87. package/dist/steps/first.d.ts +6 -5
  88. package/dist/steps/first.js +5 -4
  89. package/dist/steps/graphqlResolver.d.ts +2 -2
  90. package/dist/steps/graphqlResolver.js +44 -56
  91. package/dist/steps/groupBy.d.ts +3 -2
  92. package/dist/steps/groupBy.js +1 -2
  93. package/dist/steps/index.d.ts +4 -2
  94. package/dist/steps/index.js +21 -9
  95. package/dist/steps/lambda.d.ts +5 -5
  96. package/dist/steps/lambda.js +4 -4
  97. package/dist/steps/last.d.ts +6 -5
  98. package/dist/steps/last.js +5 -4
  99. package/dist/steps/list.d.ts +7 -7
  100. package/dist/steps/list.js +3 -3
  101. package/dist/steps/listTransform.d.ts +14 -12
  102. package/dist/steps/listTransform.js +14 -7
  103. package/dist/steps/listen.d.ts +6 -8
  104. package/dist/steps/listen.js +7 -7
  105. package/dist/steps/load.d.ts +6 -6
  106. package/dist/steps/load.js +7 -7
  107. package/dist/steps/node.d.ts +16 -10
  108. package/dist/steps/node.js +14 -7
  109. package/dist/steps/object.d.ts +11 -11
  110. package/dist/steps/object.js +5 -5
  111. package/dist/steps/partitionByIndex.d.ts +3 -2
  112. package/dist/steps/partitionByIndex.js +1 -2
  113. package/dist/steps/polymorphicBranch.d.ts +8 -8
  114. package/dist/steps/polymorphicBranch.js +4 -4
  115. package/dist/steps/proxy.d.ts +8 -8
  116. package/dist/steps/proxy.js +3 -3
  117. package/dist/steps/remapKeys.d.ts +6 -6
  118. package/dist/steps/remapKeys.js +3 -3
  119. package/dist/steps/reverse.d.ts +5 -5
  120. package/dist/steps/reverse.js +4 -4
  121. package/dist/steps/setter.d.ts +9 -18
  122. package/dist/steps/setter.js +24 -14
  123. package/dist/steps/sideEffect.d.ts +4 -4
  124. package/dist/steps/sideEffect.js +3 -3
  125. package/dist/stringifyPayload.js +1 -2
  126. package/dist/stripAnsi.js +2 -2
  127. package/dist/subscribe.js +2 -3
  128. package/dist/timeSource.d.ts +0 -1
  129. package/dist/utils.d.ts +43 -31
  130. package/dist/utils.js +97 -61
  131. package/dist/version.d.ts +1 -1
  132. package/dist/version.js +1 -1
  133. package/package.json +2 -2
package/dist/args.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hookArgs = void 0;
3
+ exports.hookArgs = hookArgs;
4
4
  const interfaces_js_1 = require("./interfaces.js");
5
5
  const middleware_js_1 = require("./middleware.js");
6
6
  const utils_js_1 = require("./utils.js");
@@ -29,7 +29,7 @@ function hookArgs(rawArgs, legacyResolvedPreset, legacyCtx) {
29
29
  }
30
30
  const middleware = rawMiddleware === undefined && resolvedPreset != null
31
31
  ? (0, middleware_js_1.getGrafastMiddleware)(resolvedPreset)
32
- : rawMiddleware ?? null;
32
+ : (rawMiddleware ?? null);
33
33
  if (rawMiddleware === undefined) {
34
34
  rawArgs.middleware = middleware;
35
35
  }
@@ -46,7 +46,6 @@ function hookArgs(rawArgs, legacyResolvedPreset, legacyCtx) {
46
46
  return finalize(args);
47
47
  }
48
48
  }
49
- exports.hookArgs = hookArgs;
50
49
  function finalize(args) {
51
50
  const userContext = args.resolvedPreset?.grafast?.context;
52
51
  const contextValue = args.contextValue;
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.strictEqual = exports.ok = void 0;
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
@@ -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 = void 0;
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++) {
@@ -107,5 +107,4 @@ function matchesConstraints(constraints, object) {
107
107
  }
108
108
  return true;
109
109
  }
110
- exports.matchesConstraints = matchesConstraints;
111
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 = void 0;
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.noop = exports.isTest = exports.isDev = void 0;
3
+ exports.isTest = exports.isDev = void 0;
4
+ exports.noop = noop;
4
5
  /**
5
6
  * @internal
6
7
  */
@@ -13,7 +14,6 @@ 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") {
@@ -1,5 +1,5 @@
1
1
  import type { Bucket } from "../bucket.js";
2
- import type { ExecutableStep } from "../step";
2
+ import type { Step } from "../step";
3
3
  import type { OperationPlan } from "./OperationPlan";
4
4
  /** Non-branching, non-deferred */
5
5
  export interface LayerPlanReasonRoot {
@@ -15,7 +15,12 @@ export interface LayerPlanReasonNullableField {
15
15
  *
16
16
  * Also needed for execution (see `executeBucket`).
17
17
  */
18
- parentStep: ExecutableStep;
18
+ parentStep: Step;
19
+ }
20
+ export interface LayerPlanReasonListItemStream {
21
+ initialCountStepId?: number;
22
+ ifStepId?: number;
23
+ labelStepId?: number;
19
24
  }
20
25
  /** Non-branching, non-deferred */
21
26
  export interface LayerPlanReasonListItem {
@@ -27,12 +32,11 @@ export interface LayerPlanReasonListItem {
27
32
  *
28
33
  * Also needed for execution (see `executeBucket`).
29
34
  */
30
- parentStep: ExecutableStep;
31
- /** If this listItem is to be streamed, the configuration for that streaming */
32
- stream?: {
33
- initialCount: number;
34
- label?: string;
35
- };
35
+ parentStep: Step;
36
+ /**
37
+ * If this listItem is to be streamed, the configuration for that streaming.
38
+ */
39
+ stream?: LayerPlanReasonListItemStream;
36
40
  }
37
41
  /** Non-branching, deferred */
38
42
  export interface LayerPlanReasonSubscription {
@@ -55,20 +59,20 @@ export interface LayerPlanReasonPolymorphic {
55
59
  /**
56
60
  * Needed for execution (see `executeBucket`).
57
61
  */
58
- parentStep: ExecutableStep;
62
+ parentStep: Step;
59
63
  polymorphicPaths: Set<string>;
60
64
  }
61
65
  /** Non-branching, non-deferred */
62
66
  export interface LayerPlanReasonSubroutine {
63
67
  type: "subroutine";
64
- parentStep: ExecutableStep;
68
+ parentStep: Step;
65
69
  }
66
- export declare function isBranchingLayerPlan(layerPlan: LayerPlan<any>): boolean;
67
- export declare function isDeferredLayerPlan(layerPlan: LayerPlan<any>): boolean;
68
- export declare function isPolymorphicLayerPlan(layerPlan: LayerPlan<any>): boolean;
70
+ export declare function isBranchingLayerPlan(layerPlan: LayerPlan): boolean;
71
+ export declare function isDeferredLayerPlan(layerPlan: LayerPlan): boolean;
72
+ export declare function isPolymorphicLayerPlan(layerPlan: LayerPlan): boolean;
69
73
  export type LayerPlanReason = LayerPlanReasonRoot | LayerPlanReasonNullableField | LayerPlanReasonListItem | LayerPlanReasonSubscription | LayerPlanReasonMutationField | LayerPlanReasonDefer | LayerPlanReasonPolymorphic | LayerPlanReasonSubroutine;
70
74
  export type HasParent<A extends LayerPlanReason> = A extends any ? A extends {
71
- parentStep: ExecutableStep;
75
+ parentStep: Step;
72
76
  } ? A : never : never;
73
77
  export type LayerPlanReasonsWithParentStep = HasParent<LayerPlanReason>;
74
78
  /**
@@ -109,12 +113,12 @@ export declare class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason
109
113
  * An optimization for OperationPlan.getPeers; this tracks the steps in this
110
114
  * layer plan, grouped by their step class.
111
115
  */
112
- stepsByConstructor: Map<Function, Set<ExecutableStep>>;
116
+ stepsByConstructor: Map<Function, Set<Step>>;
113
117
  constructor(operationPlan: OperationPlan, parentLayerPlan: LayerPlan | null, reason: TReason);
114
118
  toString(): string;
115
119
  print(depth?: number): string;
116
120
  _hasSetRootStep: boolean;
117
- setRootStep($root: ExecutableStep): void;
121
+ setRootStep($root: Step): void;
118
122
  finalize(): void;
119
123
  newBucket(parentBucket: Bucket): Bucket | null;
120
124
  }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LayerPlan = exports.isPolymorphicLayerPlan = exports.isDeferredLayerPlan = exports.isBranchingLayerPlan = void 0;
3
+ exports.LayerPlan = void 0;
4
+ exports.isBranchingLayerPlan = isBranchingLayerPlan;
5
+ exports.isDeferredLayerPlan = isDeferredLayerPlan;
6
+ exports.isPolymorphicLayerPlan = isPolymorphicLayerPlan;
4
7
  const tslib_1 = require("tslib");
5
8
  const lru_1 = tslib_1.__importDefault(require("@graphile/lru"));
6
9
  const tamedevil_1 = tslib_1.__importDefault(require("tamedevil"));
@@ -12,20 +15,17 @@ const executeBucket_js_1 = require("./executeBucket.js");
12
15
  function isBranchingLayerPlan(layerPlan) {
13
16
  return layerPlan.reason.type === "polymorphic";
14
17
  }
15
- exports.isBranchingLayerPlan = isBranchingLayerPlan;
16
18
  function isDeferredLayerPlan(layerPlan) {
17
19
  const t = layerPlan.reason.type;
18
- return (t === "stream" ||
20
+ return ((t === "listItem" && layerPlan.reason.stream != null) ||
19
21
  t === "subscription" ||
20
22
  t === "mutationField" ||
21
23
  t === "defer");
22
24
  }
23
- exports.isDeferredLayerPlan = isDeferredLayerPlan;
24
25
  function isPolymorphicLayerPlan(layerPlan) {
25
26
  const t = layerPlan.reason.type;
26
27
  return t === "polymorphic";
27
28
  }
28
- exports.isPolymorphicLayerPlan = isPolymorphicLayerPlan;
29
29
  /**
30
30
  * A LayerPlan represents (via "reason") either the root (root), when something
31
31
  * happens at a later time (mutationField, defer), when plurality changes
@@ -65,7 +65,6 @@ class LayerPlan {
65
65
  *
66
66
  * - root: the `operationPlan.rootValue`
67
67
  * - listItem: the `__ItemStep`
68
- * - stream: also the `__ItemStep`
69
68
  * - subscription: also the `__ItemStep`
70
69
  * - mutationField: the result plan of the mutation field
71
70
  * - defer: the parent layer's rootStep (defer always results in an object, unless an error occurs)
@@ -185,10 +184,6 @@ class LayerPlan {
185
184
  _addStep(step) {
186
185
  return this.operationPlan._addStep(step);
187
186
  }
188
- /** @internal */
189
- _addModifierStep(step) {
190
- return this.operationPlan._addModifierStep(step);
191
- }
192
187
  finalize() {
193
188
  if (
194
189
  // this.reason.type === "nullableBoundary" ||
@@ -2,7 +2,7 @@ import type { FragmentDefinitionNode, GraphQLFieldMap, GraphQLObjectType, GraphQ
2
2
  import type { Constraint } from "../constraints.js";
3
3
  import type { SelectionSetDigest } from "../graphqlCollectFields.js";
4
4
  import type { GrafastPlanJSON } from "../index.js";
5
- import { ExecutableStep } from "../index.js";
5
+ import { Step } from "../index.js";
6
6
  import { $$timeout, $$ts } from "../interfaces.js";
7
7
  import type { LayerPlanReasonSubroutine } from "./LayerPlan.js";
8
8
  import { LayerPlan } from "./LayerPlan.js";
@@ -54,11 +54,6 @@ export declare class OperationPlan {
54
54
  * Gets updated as we work our way through the plan, useful for making errors more helpful.
55
55
  */
56
56
  loc: string[] | null;
57
- private modifierStepCount;
58
- private modifierDepthCount;
59
- private modifierSteps;
60
- private maxDeduplicatedStepId;
61
- private maxValidatedStepId;
62
57
  /**
63
58
  * If true, then this operation doesn't use (custom) resolvers.
64
59
  */
@@ -95,7 +90,7 @@ export declare class OperationPlan {
95
90
  * create one item plan per parent plan.
96
91
  */
97
92
  private itemStepForListStep;
98
- processGroupedFieldSet(outputPlan: OutputPlan, path: readonly string[], polymorphicPath: string | null, polymorphicPaths: ReadonlySet<string> | null, parentStep: ExecutableStep, objectType: GraphQLObjectType, objectTypeFields: GraphQLFieldMap<any, any>, isMutation: boolean, groupedFieldSet: SelectionSetDigest): void;
93
+ processGroupedFieldSet(outputPlan: OutputPlan, path: readonly string[], polymorphicPath: string | null, polymorphicPaths: ReadonlySet<string> | null, parentStep: Step, objectType: GraphQLObjectType, objectTypeFields: GraphQLFieldMap<any, any>, isMutation: boolean, groupedFieldSet: SelectionSetDigest): void;
99
94
  /**
100
95
  *
101
96
  * @param outputPlan - The output plan that this selection set is being added to
@@ -106,6 +101,7 @@ export declare class OperationPlan {
106
101
  * @param isMutation - If true this selection set should be executed serially rather than in parallel (each field gets its own LayerPlan)
107
102
  */
108
103
  private planSelectionSet;
104
+ private internalDependency;
109
105
  private planIntoOutputPlan;
110
106
  private polymorphicLayerPlanByPathByLayerPlan;
111
107
  private getPolymorphicLayerPlan;
@@ -117,7 +113,6 @@ export declare class OperationPlan {
117
113
  * @see https://spec.graphql.org/draft/#CoerceArgumentValues()
118
114
  */
119
115
  private getTrackedArguments;
120
- withModifiers<T>(cb: () => T): T;
121
116
  /**
122
117
  * Sets up tracking for the given value (variableValues, context, rootValue).
123
118
  */
@@ -164,7 +159,6 @@ export declare class OperationPlan {
164
159
  private hoistAndDeduplicate;
165
160
  private hoistSteps;
166
161
  private pushDownSteps;
167
- private getStepOptionsForStep;
168
162
  /**
169
163
  * Calls the 'optimize' method on a plan, which may cause the plan to
170
164
  * communicate with its (deep) dependencies, and even to replace itself with
@@ -186,9 +180,9 @@ export declare class OperationPlan {
186
180
  private finalizeOutputPlans;
187
181
  private walkOutputPlans;
188
182
  generatePlanJSON(): GrafastPlanJSON;
189
- finishSubroutine(subroutineStep: ExecutableStep, layerPlan: LayerPlan<LayerPlanReasonSubroutine>): void;
190
- getStepsByMetaKey(metaKey: string | number | symbol): ExecutableStep[];
191
- getStepsByStepClass<TClass extends ExecutableStep>(klass: {
183
+ finishSubroutine(subroutineStep: Step, layerPlan: LayerPlan<LayerPlanReasonSubroutine>): void;
184
+ getStepsByMetaKey(metaKey: string | number | symbol): Step[];
185
+ getStepsByStepClass<TClass extends Step>(klass: {
192
186
  new (...args: any[]): TClass;
193
187
  }): TClass[];
194
188
  private _cacheStepStoreByLayerPlanAndActionKey;
@@ -197,13 +191,18 @@ export declare class OperationPlan {
197
191
  * need to regenerate it on future calls, significantly reducing the load on
198
192
  * deduplication later.
199
193
  *
194
+ * Note: automatically extends the cached step into other (relevant)
195
+ * polymorphic paths; if this shouldn't be the case then don't use cacheStep
196
+ * and instead rely on deduplication as usual.
197
+ *
200
198
  * @experimental
201
199
  */
202
- cacheStep<T extends ExecutableStep>(ownerStep: ExecutableStep, actionKey: string, cacheKey: symbol | string | number | boolean | null | undefined, cb: () => T): T;
200
+ cacheStep<T extends Step>(ownerStep: Step, actionKey: string, cacheKey: symbol | string | number | boolean | null | undefined, cb: () => T): T;
203
201
  /**
204
202
  * Clears the cache, typically due to side effects having taken place. Called
205
203
  * from setting hasSideEffects on an ExecutableStep, among other places.
206
204
  */
207
205
  resetCache(): void;
206
+ withRootLayerPlan<T>(cb: () => T): T;
208
207
  }
209
208
  //# sourceMappingURL=OperationPlan.d.ts.map