grafast 0.0.1-alpha.13 → 0.0.1-alpha.15

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 (66) hide show
  1. package/dist/args.d.ts +7 -5
  2. package/dist/assert.d.ts +2 -0
  3. package/dist/bucket.d.ts +64 -0
  4. package/dist/constraints.d.ts +31 -0
  5. package/dist/deferred.d.ts +7 -0
  6. package/dist/dev.d.ts +3 -0
  7. package/dist/engine/LayerPlan.d.ts +131 -0
  8. package/dist/engine/OperationPlan.d.ts +151 -0
  9. package/dist/engine/OutputPlan.d.ts +105 -1
  10. package/dist/engine/StepTracker.d.ts +53 -0
  11. package/dist/engine/executeBucket.d.ts +2 -0
  12. package/dist/engine/executeOutputPlan.d.ts +41 -0
  13. package/dist/envelop.d.ts +12 -0
  14. package/dist/envelop.js +4 -4
  15. package/dist/error.d.ts +23 -0
  16. package/dist/establishOperationPlan.d.ts +7 -0
  17. package/dist/execute.d.ts +8 -0
  18. package/dist/exportAs.d.ts +14 -0
  19. package/dist/grafastGraphql.d.ts +8 -3
  20. package/dist/grafastPrint.d.ts +8 -0
  21. package/dist/graphqlCollectFields.d.ts +22 -0
  22. package/dist/graphqlMergeSelectionSets.d.ts +4 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +4 -4
  25. package/dist/input.d.ts +7 -0
  26. package/dist/interfaces.d.ts +267 -5
  27. package/dist/makeGrafastSchema.d.ts +27 -0
  28. package/dist/mermaid.d.ts +28 -0
  29. package/dist/polymorphic.d.ts +8 -0
  30. package/dist/prepare.d.ts +16 -0
  31. package/dist/step.d.ts +183 -0
  32. package/dist/steps/__inputDynamicScalar.d.ts +3 -0
  33. package/dist/steps/__inputList.d.ts +3 -0
  34. package/dist/steps/__inputObject.d.ts +3 -0
  35. package/dist/steps/__inputStaticLeaf.d.ts +5 -0
  36. package/dist/steps/__item.d.ts +8 -0
  37. package/dist/steps/__trackedValue.d.ts +74 -0
  38. package/dist/steps/__value.d.ts +5 -0
  39. package/dist/steps/access.d.ts +19 -0
  40. package/dist/steps/applyTransforms.d.ts +13 -0
  41. package/dist/steps/connection.d.ts +47 -0
  42. package/dist/steps/constant.d.ts +7 -0
  43. package/dist/steps/each.d.ts +3 -0
  44. package/dist/steps/filter.d.ts +4 -0
  45. package/dist/steps/first.d.ts +4 -0
  46. package/dist/steps/graphqlResolver.d.ts +18 -0
  47. package/dist/steps/groupBy.d.ts +6 -0
  48. package/dist/steps/index.d.ts +4 -0
  49. package/dist/steps/lambda.d.ts +8 -0
  50. package/dist/steps/last.d.ts +4 -0
  51. package/dist/steps/list.d.ts +7 -0
  52. package/dist/steps/listTransform.d.ts +21 -0
  53. package/dist/steps/listen.d.ts +16 -0
  54. package/dist/steps/load.d.ts +13 -0
  55. package/dist/steps/node.d.ts +12 -0
  56. package/dist/steps/object.d.ts +15 -0
  57. package/dist/steps/partitionByIndex.d.ts +35 -0
  58. package/dist/steps/proxy.d.ts +11 -0
  59. package/dist/steps/remapKeys.d.ts +8 -0
  60. package/dist/steps/reverse.d.ts +9 -0
  61. package/dist/subscribe.d.ts +4 -0
  62. package/dist/utils.d.ts +102 -0
  63. package/dist/version.d.ts +1 -1
  64. package/fwd/graphql/index.d.ts +1 -0
  65. package/fwd/graphql/index.js +1 -0
  66. package/package.json +2 -2
package/dist/args.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import type { ExecutionArgs } from "graphql";
2
- declare const $$hooked: unique symbol;
3
- export declare function hookArgs(args: ExecutionArgs & {
4
- [$$hooked]?: boolean;
5
- }, resolvedPreset: GraphileConfig.ResolvedPreset, ctx: Partial<Grafast.RequestContext>): ExecutionArgs | PromiseLike<ExecutionArgs>;
6
- export {};
2
+ /**
3
+ * Applies Graphile Config hooks to your GraphQL request, e.g. to
4
+ * populate context or similar.
5
+ *
6
+ * @experimental
7
+ */
8
+ export declare function hookArgs(rawArgs: ExecutionArgs, resolvedPreset: GraphileConfig.ResolvedPreset, ctx: Partial<Grafast.RequestContext>): Grafast.ExecutionArgs | PromiseLike<Grafast.ExecutionArgs>;
7
9
  //# sourceMappingURL=args.d.ts.map
package/dist/assert.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** Equivalent to `assert.ok(...)` */
1
2
  export declare function ok(val: any, message: string): asserts val;
3
+ /** Equivalent to `assert.strictEqual(...)` */
2
4
  export declare function strictEqual<T>(actual: any, expected: T, message: string): asserts actual is T;
3
5
  //# sourceMappingURL=assert.d.ts.map
package/dist/bucket.d.ts CHANGED
@@ -1,21 +1,85 @@
1
1
  import type { LayerPlan } from "./engine/LayerPlan";
2
2
  import type { MetaByMetaKey } from "./engine/OperationPlan";
3
3
  import type { ExecutionEventEmitter } from "./interfaces.js";
4
+ /**
5
+ * @internal
6
+ */
4
7
  export interface RequestTools {
8
+ /** The `timeSource.now()` at which the request started executing */
5
9
  startTime: number;
10
+ /** The `timeSource.now()` at which the request should stop executing (if a timeout was configured) */
6
11
  stopTime: number | null;
7
12
  readonly eventEmitter: ExecutionEventEmitter | undefined;
13
+ /**
14
+ * If we're running inside GraphQL then we should not serialize scalars,
15
+ * otherwise we'll face the double-serialization problem.
16
+ */
8
17
  insideGraphQL: false;
9
18
  }
19
+ /**
20
+ * A "bucket" is where the results from plans are stored so that other plans
21
+ * can retrieve them, it may take on different forms depending on the mode of
22
+ * execution. A "LayerPlan" is used to both identify the bucket and to specify
23
+ * why it exists and how it behaves.
24
+ *
25
+ * Every `ExecutableStep` belongs to exactly one LayerPlan (and thus bucket),
26
+ * specified by `plan.layerPlan`.
27
+ *
28
+ * @internal
29
+ */
10
30
  export interface Bucket {
31
+ /**
32
+ * The LayerPlan definition this bucket adheres to
33
+ */
11
34
  layerPlan: LayerPlan;
35
+ /**
36
+ * How many entries are there in the bucket?
37
+ */
12
38
  size: number;
39
+ /**
40
+ * The polymorphic path through which each of the entries (respectively) has
41
+ * travelled. This influences the steps that will be executed using the
42
+ * related inputs.
43
+ */
13
44
  polymorphicPathList: readonly (string | null)[];
45
+ /**
46
+ * These are the iterators the bucket (or its descendents, without crossing a
47
+ * stream/defer boundary) have created (if any). Each of these must either be
48
+ * processed via `processRoot`, or must be manually released (via
49
+ * `releaseUnusedIterators`) otherwise a memory leak could occur.
50
+ */
14
51
  iterators: Array<Set<AsyncIterator<any> | Iterator<any>>>;
52
+ /**
53
+ * `metaByMetaKey` belongs to the bucket rather than the request context
54
+ * because mutations and subscriptions shouldn't re-use caches.
55
+ *
56
+ * TODO: `inheritMeta: boolean`?
57
+ */
15
58
  metaByMetaKey: MetaByMetaKey;
59
+ /**
60
+ * Every entry in the store is a list with the same length as the bucket has
61
+ * `size`.
62
+ *
63
+ * The entry for '-1' is the request indexes, so we can associate the results
64
+ * back to the request that triggered them.
65
+ */
16
66
  store: Map<number, any[]>;
67
+ /**
68
+ * Set this true when the bucket is fully executed.
69
+ *
70
+ * Initialize it to false.
71
+ */
17
72
  isComplete: boolean;
73
+ /**
74
+ * If an error occurred at any stage we need to drop down to more careful
75
+ * (and slower) handling.
76
+ *
77
+ * Initialize it to false.
78
+ */
18
79
  hasErrors: boolean;
80
+ /**
81
+ * The child buckets of this bucket.
82
+ */
19
83
  children: {
20
84
  [layerPlanId: number]: {
21
85
  bucket: Bucket;
@@ -1,30 +1,61 @@
1
+ /**
2
+ * Asserts that a value strictly matches.
3
+ */
1
4
  interface ValueConstraint {
2
5
  type: "value";
3
6
  path: (string | number)[];
4
7
  value: unknown;
5
8
  }
9
+ /**
10
+ * Asserts that `(value === expectedValue)` is always equal to `pass`.
11
+ */
6
12
  interface EqualityConstraint {
7
13
  type: "equal";
8
14
  path: (string | number)[];
9
15
  expectedValue: unknown;
10
16
  pass: boolean;
11
17
  }
18
+ /**
19
+ * Asserts that the property at the given path exists.
20
+ *
21
+ * Let `tail` be the last entry in `path`, and `rest` be the rest of `path`.
22
+ * The value at path `rest` must be an object, and that object must have an
23
+ * attribute `tail` which is not `undefined`.
24
+ */
12
25
  interface ExistsConstraint {
13
26
  type: "exists";
14
27
  path: (string | number)[];
15
28
  exists: boolean;
16
29
  }
30
+ /**
31
+ * If `expectedLength` is null: asserts that there is no value at the given
32
+ * path.
33
+ *
34
+ * Otherwise: asserts that the value at the given path is an array containing
35
+ * `expectedLength` entries.
36
+ */
17
37
  interface LengthConstraint {
18
38
  type: "length";
19
39
  path: (string | number)[];
40
+ /**
41
+ * If this is null it implies that the array did not exist.
42
+ */
20
43
  expectedLength: number | null;
21
44
  }
45
+ /**
46
+ * Checks if the object at the given path matches the `isEmpty` property
47
+ * (implying no keys). Objects are empty if and only if they exist and have no
48
+ * keys.
49
+ */
22
50
  interface IsEmptyConstraint {
23
51
  type: "isEmpty";
24
52
  path: (string | number)[];
25
53
  isEmpty: boolean;
26
54
  }
27
55
  export type Constraint = ValueConstraint | EqualityConstraint | ExistsConstraint | LengthConstraint | IsEmptyConstraint;
56
+ /**
57
+ * Implements the `MatchesConstraints` algorithm.
58
+ */
28
59
  export declare function matchesConstraints(constraints: Constraint[], object: unknown): boolean;
29
60
  export {};
30
61
  //# sourceMappingURL=constraints.d.ts.map
@@ -1,6 +1,13 @@
1
+ /**
2
+ * A promise that can be `.resolve()`-ed or `.reject()`-ed at a later time.
3
+ */
1
4
  export interface Deferred<T> extends PromiseLike<T> {
2
5
  resolve: (input: T | PromiseLike<T>) => void;
3
6
  reject: (error: Error) => void;
4
7
  }
8
+ /**
9
+ * Returns a promise that can be `.resolve()`-ed or `.reject()`-ed at a later
10
+ * time.
11
+ */
5
12
  export declare function defer<T = void>(): Deferred<T>;
6
13
  //# sourceMappingURL=deferred.d.ts.map
package/dist/dev.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @internal
3
+ */
1
4
  export declare const isDev: boolean;
2
5
  export declare function noop(): void;
3
6
  //# sourceMappingURL=dev.d.ts.map
@@ -1,38 +1,64 @@
1
1
  import type { Bucket } from "../bucket.js";
2
2
  import type { ExecutableStep, ModifierStep, UnbatchedExecutableStep } from "../step";
3
3
  import type { OperationPlan } from "./OperationPlan";
4
+ /** Non-branching, non-deferred */
4
5
  export interface LayerPlanReasonRoot {
5
6
  type: "root";
6
7
  }
8
+ /** Non-branching, non-deferred */
7
9
  export interface LayerPlanReasonNullableField {
8
10
  type: "nullableBoundary";
11
+ /**
12
+ * Can be used such that the same LayerPlan can be used for two selection
13
+ * sets for the same parent plan. In this case an additional output plan
14
+ * would be added to the LayerPlan.
15
+ *
16
+ * Also needed for execution (see `executeBucket`).
17
+ */
9
18
  parentStep: ExecutableStep;
10
19
  }
20
+ /** Non-branching, non-deferred */
11
21
  export interface LayerPlanReasonListItem {
12
22
  type: "listItem";
23
+ /**
24
+ * Can be used such that the same LayerPlan can be used for two lists for
25
+ * the same parent plan. In this case an additional output plan would be
26
+ * added to the LayerPlan.
27
+ *
28
+ * Also needed for execution (see `executeBucket`).
29
+ */
13
30
  parentStep: ExecutableStep;
31
+ /** If this listItem is to be streamed, the configuration for that streaming */
14
32
  stream?: {
15
33
  initialCount: number;
16
34
  label?: string;
17
35
  };
18
36
  }
37
+ /** Non-branching, deferred */
19
38
  export interface LayerPlanReasonSubscription {
20
39
  type: "subscription";
21
40
  }
41
+ /** Non-branching, deferred */
22
42
  export interface LayerPlanReasonMutationField {
23
43
  type: "mutationField";
24
44
  mutationIndex: number;
25
45
  }
46
+ /** Non-branching, deferred */
26
47
  export interface LayerPlanReasonDefer {
27
48
  type: "defer";
28
49
  label?: string;
29
50
  }
51
+ /** Branching, non-deferred */
30
52
  export interface LayerPlanReasonPolymorphic {
31
53
  type: "polymorphic";
32
54
  typeNames: string[];
55
+ /**
56
+ * Needed for execution (see `executeBucket`).
57
+ */
33
58
  parentStep: ExecutableStep;
34
59
  polymorphicPaths: Set<string>;
35
60
  }
61
+ /** Non-branching, non-deferred */
36
62
  export interface LayerPlanReasonSubroutine {
37
63
  type: "subroutine";
38
64
  parentStep: ExecutableStep;
@@ -45,38 +71,143 @@ export type HasParent<A extends LayerPlanReason> = A extends any ? A extends {
45
71
  parentStep: ExecutableStep;
46
72
  } ? A : never : never;
47
73
  export type LayerPlanReasonsWithParentStep = HasParent<LayerPlanReason>;
74
+ /** @internal */
48
75
  export interface LayerPlanPhase {
76
+ /**
77
+ * If true, we should check before the layer plan executes to see if the
78
+ * execution has already timed out.
79
+ *
80
+ * @see {@link RequestTools.stopTime}
81
+ */
49
82
  checkTimeout: boolean;
83
+ /**
84
+ * A list of steps that can be ran in parallel at this point, since all
85
+ * their previous dependencies have already been satisfied.
86
+ */
50
87
  normalSteps: Array<{
51
88
  step: ExecutableStep;
52
89
  }> | undefined;
90
+ /**
91
+ * A list of 'isSyncAndSafe' steps with unbatchedExecute methods that can be
92
+ * ran once the `normalSteps` have completed; they must only depend on steps
93
+ * that have already been executed before them (including previous
94
+ * unbatchedSyncAndSafeSteps in the same list).
95
+ */
53
96
  unbatchedSyncAndSafeSteps: Array<{
54
97
  step: UnbatchedExecutableStep;
98
+ /**
99
+ * Store the result of the step here if you want - useful to avoid lookups
100
+ * and when there's no storage. HIGHLY VOLATILE, will not survive a tick!
101
+ */
55
102
  scratchpad: any;
56
103
  }> | undefined;
104
+ /**
105
+ * Optimization - a digest of all steps in normalSteps and unbatchedSyncAndSafeSteps
106
+ *
107
+ * @internal
108
+ */
57
109
  _allSteps: ExecutableStep[];
58
110
  }
111
+ /**
112
+ * A LayerPlan represents (via "reason") either the root (root), when something
113
+ * happens at a later time (mutationField, defer), when plurality changes
114
+ * (list, stream, subscription, polymorphic), or when a subprocess needs to be
115
+ * computed (subroutine).
116
+ *
117
+ * Layer plans belong to an operation plan.
118
+ *
119
+ * Every layer plan (except for the root layer plan) has exactly one parent
120
+ * layer plan.
121
+ *
122
+ * Every layer plan is caused by a parent step.
123
+ *
124
+ * The LayerPlan of a step influences:
125
+ *
126
+ * 1. how steps are deduplicated
127
+ * 2. the order in which the steps are executed
128
+ * 3. where the result of executing the step is stored
129
+ * 4. when the step execution cache is allowed to be GC'd
130
+ *
131
+ * NOTE: `__ListTransformStep`'s effectively have a temporary bucket inside
132
+ * them (built on the `__Item`) that's thrown away once the transform is
133
+ * complete.
134
+ *
135
+ */
59
136
  export declare class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason> {
60
137
  readonly operationPlan: OperationPlan;
61
138
  parentLayerPlan: LayerPlan | null;
62
139
  readonly reason: TReason;
63
140
  id: number;
141
+ /**
142
+ * Every layer plan has a "root step" that shapes the value the layer
143
+ * returns. Note that this step may be dependent on other steps included in
144
+ * the LayerPlan, or could be provided externally.
145
+ *
146
+ * The root step is different for different layer step reasons:
147
+ *
148
+ * - root: the `operationPlan.rootValue`
149
+ * - listItem: the `__ItemStep`
150
+ * - stream: also the `__ItemStep`
151
+ * - subscription: also the `__ItemStep`
152
+ * - mutationField: the result plan of the mutation field
153
+ * - defer: the parent layer's rootStep (defer always results in an object, unless an error occurs)
154
+ * - polymorphic: the plan for the particular type
155
+ * - subroutine: the result (returned) plan of the subroutine
156
+ *
157
+ * @internal
158
+ */
64
159
  readonly rootStep: ExecutableStep | null;
160
+ /**
161
+ * Which plans the results for which are available in a parent bucket need to
162
+ * be "copied across" to this bucket because plans in this bucket still
163
+ * reference them?
164
+ *
165
+ * @internal
166
+ */
65
167
  copyStepIds: number[];
168
+ /** @internal */
66
169
  children: LayerPlan[];
170
+ /** @internal */
67
171
  steps: ExecutableStep[];
172
+ /** @internal */
68
173
  pendingSteps: ExecutableStep[];
174
+ /**
175
+ * Describes the order in which the steps within this LayerPlan are executed.
176
+ *
177
+ * Special attention must be paid to steps that have side effects.
178
+ *
179
+ * @internal
180
+ */
69
181
  phases: Array<LayerPlanPhase>;
182
+ /**
183
+ * The list of layerPlans that steps added to this LayerPlan may depend upon.
184
+ * Note this includes self, so it has one more entry than `depth`.
185
+ *
186
+ * ```
187
+ * this.ancestry[this.depth] === this;
188
+ * ```
189
+ *
190
+ * @internal
191
+ */
70
192
  ancestry: LayerPlan[];
193
+ /** How "deep" this layer plan is (how many ancestors it has). The root layer plan has a depth of 0. */
71
194
  depth: number;
195
+ /** The depth at which a "defer boundary" occurs (OperationPlan.getPeers cannot pass a defer boundary), or 0. */
72
196
  deferBoundaryDepth: number;
197
+ /**
198
+ * An optimization for OperationPlan.getPeers; this tracks the steps in this
199
+ * layer plan, grouped by their step class.
200
+ */
73
201
  stepsByConstructor: Map<Function, Set<ExecutableStep>>;
74
202
  constructor(operationPlan: OperationPlan, parentLayerPlan: LayerPlan | null, reason: TReason);
75
203
  toString(): string;
76
204
  print(depth?: number): string;
77
205
  setRootStep($root: ExecutableStep): void;
206
+ /** @internal Use plan.getStep(id) instead. */
78
207
  getStep(id: number, requestingStep: ExecutableStep): ExecutableStep;
208
+ /** @internal */
79
209
  _addStep(step: ExecutableStep): number;
210
+ /** @internal */
80
211
  _addModifierStep(step: ModifierStep<any>): string;
81
212
  finalize(): void;
82
213
  newBucket(parentBucket: Bucket): Bucket | null;
@@ -11,6 +11,7 @@ import { OutputPlan } from "./OutputPlan.js";
11
11
  import { StepTracker } from "./StepTracker.js";
12
12
  export declare const POLYMORPHIC_ROOT_PATH: null;
13
13
  export declare const POLYMORPHIC_ROOT_PATHS: ReadonlySet<string> | null;
14
+ /** @internal */
14
15
  export type OperationPlanPhase = "init" | "plan" | "validate" | "optimize" | "finalize" | "ready";
15
16
  export interface MetaByMetaKey {
16
17
  [metaKey: string | number | symbol]: Record<string, any>;
@@ -38,35 +39,76 @@ export declare class OperationPlan {
38
39
  [objectTypeName: string]: ReadonlyArray<GraphQLUnionType>;
39
40
  };
40
41
  private operationType;
42
+ /**
43
+ * What state is the OpPlan in?
44
+ *
45
+ * 1. init
46
+ * 2. plan
47
+ * 3. validate
48
+ * 5. optimize
49
+ * 6. finalize
50
+ * 7. ready
51
+ *
52
+ * Once in 'ready' state we can execute the plan.
53
+ *
54
+ * @internal
55
+ */
41
56
  phase: OperationPlanPhase;
57
+ /**
58
+ * Gets updated as we work our way through the plan, useful for making errors more helpful.
59
+ */
42
60
  loc: string[] | null;
61
+ /** @internal */
43
62
  rootLayerPlan: LayerPlan;
63
+ /**
64
+ * Assigned during OperationPlan.planOperation(), guaranteed to exist after
65
+ * initialization.
66
+ *
67
+ * @internal
68
+ */
44
69
  rootOutputPlan: OutputPlan;
45
70
  private modifierStepCount;
46
71
  private modifierDepthCount;
47
72
  private modifierSteps;
73
+ /** @internal */
48
74
  readonly stepTracker: StepTracker;
49
75
  private maxDeduplicatedStepId;
50
76
  private maxValidatedStepId;
77
+ /** Constraints based on evaluating variables. @internal */
51
78
  readonly variableValuesConstraints: Constraint[];
79
+ /** Stores the actual variableValues. @internal */
52
80
  readonly variableValuesStep: __ValueStep<{
53
81
  [key: string]: any;
54
82
  }>;
83
+ /** A step for accessing variableValues in a tracked manner (allowing eval). @internal */
55
84
  readonly trackedVariableValuesStep: __TrackedValueStep<{
56
85
  [key: string]: any;
57
86
  }>;
87
+ /** Constraints based on evaluating context. @internal */
58
88
  readonly contextConstraints: Constraint[];
89
+ /** Stores the actual value of the context. @internal */
59
90
  readonly contextStep: __ValueStep<Grafast.Context>;
91
+ /** Allows accessing context in a tracked manner (allowing eval). @internal */
60
92
  readonly trackedContextStep: __TrackedValueStep<{
61
93
  [key: string]: any;
62
94
  }>;
95
+ /** Constraints based on evaluating rootValue. @internal */
63
96
  readonly rootValueConstraints: Constraint[];
97
+ /** Stores the actual value of rootValue. @internal */
64
98
  readonly rootValueStep: __ValueStep<any>;
99
+ /** Allows accessing rootValue in a tracked manner (allowing eval). @internal */
65
100
  readonly trackedRootValueStep: __TrackedValueStep<any>;
101
+ /** @internal */
66
102
  makeMetaByMetaKey: () => MetaByMetaKey;
103
+ /**
104
+ * @internal
105
+ */
67
106
  readonly itemStepIdByListStepId: {
68
107
  [listStepId: number]: number | undefined;
69
108
  };
109
+ /**
110
+ * If true, then this operation doesn't use (custom) resolvers.
111
+ */
70
112
  pure: boolean;
71
113
  private startTime;
72
114
  private previousLap;
@@ -82,50 +124,159 @@ export declare class OperationPlan {
82
124
  }, rootValue: any, planningTimeout: number | null);
83
125
  private lap;
84
126
  private checkTimeout;
127
+ /**
128
+ * Called by the LayerPlan's constructor when it wants to get a new id to use.
129
+ *
130
+ * @internal
131
+ */
85
132
  addLayerPlan(layerPlan: LayerPlan): number;
133
+ /**
134
+ * Adds a plan to the known steps and returns the number to use as the plan
135
+ * id. ONLY to be used from Step, user code should never call this directly.
136
+ *
137
+ * @internal
138
+ */
86
139
  _addStep(plan: ExecutableStep): number;
140
+ /**
141
+ * Adds a plan to the known steps and returns the number to use as the plan
142
+ * id. ONLY to be used from Step, user code should never call this directly.
143
+ *
144
+ * @internal
145
+ */
87
146
  _addModifierStep(step: ModifierStep<any>): string;
147
+ /** @internal Use plan.getStep(id) instead. */
88
148
  getStep: (id: number, requestingStep: ExecutableStep) => ExecutableStep;
149
+ /**
150
+ * Get a plan without specifying who requested it; this disables all the
151
+ * caller checks. Only intended to be called from internal code.
152
+ *
153
+ * @internal
154
+ */
89
155
  dangerouslyGetStep(id: number): ExecutableStep;
90
156
  private planOperation;
157
+ /**
158
+ * Plans a GraphQL query operation.
159
+ */
91
160
  private planQuery;
161
+ /**
162
+ * Implements the `PlanOpPlanMutation` algorithm.
163
+ */
92
164
  private planMutation;
165
+ /**
166
+ * Implements the `PlanOpPlanSubscription` algorithm.
167
+ */
93
168
  private planSubscription;
169
+ /**
170
+ * Gets the item plan for a given parent list plan - this ensures we only
171
+ * create one item plan per parent plan.
172
+ */
94
173
  private itemStepForListStep;
95
174
  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;
175
+ /**
176
+ *
177
+ * @param outputPlan - The output plan that this selection set is being added to
178
+ * @param path - The path within the outputPlan that we're adding stuff (only for root/object OutputPlans)
179
+ * @param parentStep - The step that represents the selection set root
180
+ * @param objectType - The object type that this selection set is being evaluated for (note polymorphic selection should already have been handled by this point)
181
+ * @param selections - The GraphQL selections (fields, fragment spreads, inline fragments) to evaluate
182
+ * @param isMutation - If true this selection set should be executed serially rather than in parallel (each field gets its own LayerPlan)
183
+ */
96
184
  private planSelectionSet;
97
185
  private planIntoOutputPlan;
98
186
  private polymorphicLayerPlanByPathByLayerPlan;
99
187
  private getPolymorphicLayerPlan;
100
188
  private planField;
189
+ /**
190
+ * A replacement for GraphQL's
191
+ * `CoerceArgumentValues` that factors in tracked variables.
192
+ *
193
+ * @see https://spec.graphql.org/draft/#CoerceArgumentValues()
194
+ */
101
195
  private getTrackedArguments;
102
196
  withModifiers<T>(cb: () => T): T;
197
+ /**
198
+ * Sets up tracking for the given value (variableValues, context, rootValue).
199
+ */
103
200
  private track;
201
+ /**
202
+ * Checks that no step has a property on it whose value is another step. It
203
+ * should addDependency instead.
204
+ */
104
205
  private validateSteps;
105
206
  private replaceStep;
106
207
  private processStep;
208
+ /**
209
+ * Process the given steps, either dependencies first (root to leaf) or
210
+ * dependents first (leaves to root).
211
+ *
212
+ * @internal
213
+ */
107
214
  processSteps(actionDescription: string, order: "dependents-first" | "dependencies-first", isReadonly: boolean, callback: (plan: ExecutableStep) => ExecutableStep): void;
215
+ /**
216
+ * Peers are steps of the same type (but not the same step!) that are in
217
+ * compatible layers and have the same dependencies. Peers must not have side
218
+ * effects. A step is not its own peer.
219
+ */
108
220
  private getPeers;
109
221
  private isImmoveable;
222
+ /**
223
+ * Attempts to hoist the step into a higher layerPlan to maximize
224
+ * deduplication.
225
+ */
110
226
  private hoistStep;
227
+ /**
228
+ * Attempts to push the step into the lowest layerPlan to minimize the need
229
+ * for copying between layer plans.
230
+ */
111
231
  private pushDown;
112
232
  private _deduplicateInnerLogic;
113
233
  private deduplicateStep;
114
234
  private deduplicateStepsProcess;
235
+ /**
236
+ * Gives us a chance to replace nearly-duplicate plans with other existing
237
+ * plans (and adding the necessary transforms); this means that by the time
238
+ * we come to optimize the plan tree should already be simpler. For example
239
+ * if you have two plans at the same level that both request row data from
240
+ * the same database table with the same identifiers, `WHERE`, `LIMIT`,
241
+ * `OFFSET` and `ORDER BY`, but different `SELECT`s we could merge the two
242
+ * plans together by replacing the latter with the former and having the
243
+ * former SELECT additional fields, then transform the results back to what
244
+ * our child plans would be expecting.
245
+ */
115
246
  private deduplicateSteps;
116
247
  private hoistAndDeduplicate;
117
248
  private hoistSteps;
118
249
  private pushDownSteps;
119
250
  private getStepOptionsForStep;
251
+ /**
252
+ * Calls the 'optimize' method on a plan, which may cause the plan to
253
+ * communicate with its (deep) dependencies, and even to replace itself with
254
+ * a different plan.
255
+ */
120
256
  private optimizeStep;
257
+ /**
258
+ * Note that we work through dependents first so we can make sure that we
259
+ * know all our dependent's needs before we optimise ourself.
260
+ */
121
261
  private optimizeSteps;
262
+ /** Finalizes each step */
122
263
  private finalizeSteps;
123
264
  private finalizeLayerPlans;
265
+ /** Optimizes each output plan */
124
266
  private optimizeOutputPlans;
267
+ /** Finalizes each output plan */
125
268
  private finalizeOutputPlans;
126
269
  private walkOutputPlans;
270
+ /**
271
+ * Convert an OpPlan into a plan graph in mermaid-js format.
272
+ */
127
273
  printPlanGraph(options?: PrintPlanGraphOptions): string;
128
274
  finishSubroutine(subroutineStep: ExecutableStep, layerPlan: LayerPlan<LayerPlanReasonSubroutine>): void;
275
+ /**
276
+ * HIGHLY EXPERIMENTAL!
277
+ *
278
+ * @internal
279
+ */
129
280
  deleteLayerPlan(layerPlan: LayerPlan): void;
130
281
  getStepsByMetaKey(metaKey: string | number | symbol): ExecutableStep[];
131
282
  getStepsByStepClass<TClass extends ExecutableStep>(klass: {