grafast 0.1.1-beta.21 → 0.1.1-beta.22

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 (94) hide show
  1. package/README.md +0 -4
  2. package/dist/args.js +3 -3
  3. package/dist/constants.d.ts +79 -0
  4. package/dist/constants.js +79 -0
  5. package/dist/engine/LayerPlan.d.ts +71 -8
  6. package/dist/engine/LayerPlan.js +375 -265
  7. package/dist/engine/OperationPlan.d.ts +77 -14
  8. package/dist/engine/OperationPlan.js +1508 -382
  9. package/dist/engine/OperationPlanTypes.d.ts +66 -0
  10. package/dist/engine/OperationPlanTypes.js +3 -0
  11. package/dist/engine/OutputPlan.d.ts +6 -0
  12. package/dist/engine/OutputPlan.js +138 -82
  13. package/dist/engine/StepTracker.js +76 -17
  14. package/dist/engine/executeBucket.js +327 -166
  15. package/dist/engine/lib/defaultPlanResolver.d.ts +1 -4
  16. package/dist/engine/lib/defaultPlanResolver.js +1 -5
  17. package/dist/engine/lib/withGlobalLayerPlan.d.ts +3 -1
  18. package/dist/engine/lib/withGlobalLayerPlan.js +19 -1
  19. package/dist/envelop.js +14 -3
  20. package/dist/error.d.ts +1 -1
  21. package/dist/error.js +9 -9
  22. package/dist/establishOperationPlan.d.ts +2 -1
  23. package/dist/establishOperationPlan.js +10 -10
  24. package/dist/execute.js +7 -5
  25. package/dist/global.d.ts +10 -0
  26. package/dist/global.js +25 -0
  27. package/dist/grafastGraphql.js +4 -3
  28. package/dist/grafastPrint.js +36 -4
  29. package/dist/index.d.ts +76 -8
  30. package/dist/index.js +37 -33
  31. package/dist/input.js +20 -1
  32. package/dist/inspect.js +1 -0
  33. package/dist/interfaces.d.ts +80 -122
  34. package/dist/interfaces.js +0 -77
  35. package/dist/makeGrafastSchema.d.ts +118 -35
  36. package/dist/makeGrafastSchema.js +197 -29
  37. package/dist/mermaid.js +198 -97
  38. package/dist/operationPlan-input.d.ts +1 -1
  39. package/dist/operationPlan-input.js +15 -5
  40. package/dist/planJSONInterfaces.d.ts +24 -5
  41. package/dist/prepare.d.ts +16 -9
  42. package/dist/prepare.js +54 -51
  43. package/dist/step.d.ts +45 -9
  44. package/dist/step.js +139 -22
  45. package/dist/steps/__flag.d.ts +3 -2
  46. package/dist/steps/__flag.js +31 -29
  47. package/dist/steps/__inputObject.d.ts +1 -1
  48. package/dist/steps/__inputStaticLeaf.d.ts +3 -2
  49. package/dist/steps/__inputStaticLeaf.js +13 -7
  50. package/dist/steps/__item.d.ts +1 -1
  51. package/dist/steps/__item.js +3 -3
  52. package/dist/steps/__trackedValue.d.ts +6 -3
  53. package/dist/steps/__trackedValue.js +25 -9
  54. package/dist/steps/__value.d.ts +2 -1
  55. package/dist/steps/__value.js +5 -0
  56. package/dist/steps/access.d.ts +17 -1
  57. package/dist/steps/access.js +14 -1
  58. package/dist/steps/applyInput.d.ts +1 -1
  59. package/dist/steps/applyInput.js +7 -6
  60. package/dist/steps/applyTransforms.js +9 -7
  61. package/dist/steps/bakedInput.js +2 -2
  62. package/dist/steps/coalesce.d.ts +15 -0
  63. package/dist/steps/coalesce.js +36 -0
  64. package/dist/steps/constant.js +16 -14
  65. package/dist/steps/each.d.ts +2 -2
  66. package/dist/steps/first.d.ts +2 -0
  67. package/dist/steps/first.js +5 -1
  68. package/dist/steps/graphqlResolver.d.ts +2 -2
  69. package/dist/steps/graphqlResolver.js +63 -161
  70. package/dist/steps/index.d.ts +3 -15
  71. package/dist/steps/index.js +6 -41
  72. package/dist/steps/lambda.js +1 -1
  73. package/dist/steps/last.d.ts +2 -0
  74. package/dist/steps/last.js +4 -0
  75. package/dist/steps/listTransform.d.ts +2 -2
  76. package/dist/steps/listTransform.js +11 -13
  77. package/dist/steps/load.d.ts +28 -22
  78. package/dist/steps/load.js +47 -1
  79. package/dist/steps/node.d.ts +10 -7
  80. package/dist/steps/node.js +5 -19
  81. package/dist/steps/object.js +6 -1
  82. package/dist/steps/proxy.d.ts +0 -6
  83. package/dist/steps/proxy.js +3 -3
  84. package/dist/steps/remapKeys.d.ts +1 -1
  85. package/dist/steps/remapKeys.js +0 -1
  86. package/dist/utils.d.ts +27 -5
  87. package/dist/utils.js +235 -15
  88. package/dist/version.d.ts +1 -1
  89. package/dist/version.js +1 -1
  90. package/package.json +6 -6
  91. package/dist/polymorphic.d.ts +0 -14
  92. package/dist/polymorphic.js +0 -72
  93. package/dist/steps/polymorphicBranch.d.ts +0 -27
  94. package/dist/steps/polymorphicBranch.js +0 -62
package/dist/prepare.js CHANGED
@@ -6,6 +6,7 @@ const graphql = tslib_1.__importStar(require("graphql"));
6
6
  const execute_1 = require("graphql/execution/execute");
7
7
  const iterall_1 = require("iterall");
8
8
  const assert = tslib_1.__importStar(require("./assert.js"));
9
+ const constants_js_1 = require("./constants.js");
9
10
  const deferred_js_1 = require("./deferred.js");
10
11
  const dev_js_1 = require("./dev.js");
11
12
  const executeBucket_js_1 = require("./engine/executeBucket.js");
@@ -13,11 +14,9 @@ const executeOutputPlan_js_1 = require("./engine/executeOutputPlan.js");
13
14
  const OperationPlan_js_1 = require("./engine/OperationPlan.js");
14
15
  const OutputPlan_js_1 = require("./engine/OutputPlan.js");
15
16
  const establishOperationPlan_js_1 = require("./establishOperationPlan.js");
16
- const interfaces_js_1 = require("./interfaces.js");
17
17
  const timeSource_js_1 = require("./timeSource.js");
18
18
  const utils_js_1 = require("./utils.js");
19
19
  const { GraphQLError } = graphql;
20
- const $$contextPlanCache = Symbol("contextPlanCache");
21
20
  const $$bypassGraphQL = Symbol("bypassGraphQL");
22
21
  const bypassGraphQLObj = Object.assign(Object.create(null), {
23
22
  [$$bypassGraphQL]: true,
@@ -154,7 +153,7 @@ function outputBucket(outputPlan, rootBucket, rootBucketIndex, requestContext, p
154
153
  else {
155
154
  const c = (0, OutputPlan_js_1.getChildBucketAndIndex)(outputPlan.layerPlan, null, rootBucket, rootBucketIndex, null);
156
155
  if (!c) {
157
- throw new Error(`GrafastInternalError<8bbf56c1-8e2a-4ee9-b5fc-724fd0ee222b>: could not find relevant bucket for output plan`);
156
+ throw new Error(`GrafastInternalError<8bbf56c1-8e2a-4ee9-b5fc-724fd0ee222b>: could not find relevant bucket for output plan ${outputPlan} from ${rootBucket}[${rootBucketIndex}]`);
158
157
  }
159
158
  [childBucket, childBucketIndex] = c;
160
159
  }
@@ -180,14 +179,15 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
180
179
  store.set(operationPlan.variableValuesStep.id, (0, executeBucket_js_1.unaryExecutionValue)(variableValues));
181
180
  store.set(operationPlan.contextStep.id, (0, executeBucket_js_1.unaryExecutionValue)(context));
182
181
  store.set(operationPlan.rootValueStep.id, (0, executeBucket_js_1.unaryExecutionValue)(rootValue));
183
- const rootBucket = (0, executeBucket_js_1.newBucket)({
182
+ const rootBucket = (0, executeBucket_js_1.newBucket)(null, {
184
183
  layerPlan: operationPlan.rootLayerPlan,
185
184
  size,
186
185
  store,
187
186
  flagUnion: 0,
188
187
  polymorphicPathList,
188
+ polymorphicType: null,
189
189
  iterators,
190
- }, null);
190
+ });
191
191
  const startTime = timeSource_js_1.timeSource.now();
192
192
  const stopTime = executionTimeout !== null ? startTime + executionTimeout : null;
193
193
  const requestContext = {
@@ -195,7 +195,7 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
195
195
  startTime,
196
196
  stopTime,
197
197
  // toSerialize: [],
198
- eventEmitter: rootValue?.[interfaces_js_1.$$eventEmitter],
198
+ eventEmitter: rootValue?.[constants_js_1.$$eventEmitter],
199
199
  insideGraphQL: false,
200
200
  };
201
201
  const bucketPromise = (0, executeBucket_js_1.executeBucket)(rootBucket, requestContext);
@@ -215,20 +215,21 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
215
215
  ? (0, executeBucket_js_1.unaryExecutionValue)(payload)
216
216
  : (0, executeBucket_js_1.batchExecutionValue)([payload]);
217
217
  store.set(rootStep.id, rootExecutionValue);
218
- const subscriptionBucket = (0, executeBucket_js_1.newBucket)({
218
+ const subscriptionBucket = (0, executeBucket_js_1.newBucket)(rootBucket, {
219
219
  layerPlan,
220
220
  store,
221
221
  flagUnion: rootBucket.flagUnion,
222
222
  polymorphicPathList: [OperationPlan_js_1.POLYMORPHIC_ROOT_PATH],
223
+ polymorphicType: null,
223
224
  iterators: [new Set()],
224
225
  size: 1, //store.size
225
- }, rootBucket.metaByMetaKey);
226
+ });
226
227
  const bucketPromise = (0, executeBucket_js_1.executeBucket)(subscriptionBucket, requestContext);
227
228
  function outputStreamBucket() {
228
229
  const [ctx, result] = outputBucket(operationPlan.rootOutputPlan, subscriptionBucket, ZERO, requestContext, [], rootBucket.store
229
230
  .get(operationPlan.variableValuesStep.id)
230
231
  .at(rootBucketIndex), outputDataAsString);
231
- return finalize(result, ctx, index === 0 ? (rootValue[interfaces_js_1.$$extensions] ?? undefined) : undefined, outputDataAsString);
232
+ return finalize(result, ctx, index === 0 ? (rootValue[constants_js_1.$$extensions] ?? undefined) : undefined, outputDataAsString);
232
233
  }
233
234
  if ((0, utils_js_1.isPromiseLike)(bucketPromise)) {
234
235
  return bucketPromise.then(outputStreamBucket);
@@ -245,8 +246,8 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
245
246
  ? rootBucket.store.get(rootBucket.layerPlan.rootStep.id)
246
247
  : null;
247
248
  const bucketRootValue = bucketRootEValue?.at(rootBucketIndex);
248
- const bucketRootFlags = bucketRootEValue?._flagsAt(rootBucketIndex) ?? interfaces_js_1.NO_FLAGS;
249
- if (bucketRootFlags & interfaces_js_1.FLAG_ERROR) {
249
+ const bucketRootFlags = bucketRootEValue?._flagsAt(rootBucketIndex) ?? constants_js_1.NO_FLAGS;
250
+ if (bucketRootFlags & constants_js_1.FLAG_ERROR) {
250
251
  releaseUnusedIterators(rootBucket, rootBucketIndex, null);
251
252
  // Something major went wrong!
252
253
  const errors = [
@@ -259,7 +260,7 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
259
260
  ];
260
261
  const payload = Object.create(null);
261
262
  payload.errors = errors;
262
- const extensions = bucketRootValue[interfaces_js_1.$$extensions];
263
+ const extensions = bucketRootValue[constants_js_1.$$extensions];
263
264
  if (extensions != null) {
264
265
  payload.extensions = extensions;
265
266
  }
@@ -269,11 +270,11 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
269
270
  if (bucketRootValue != null &&
270
271
  subscriptionLayerPlan != null &&
271
272
  Array.isArray(bucketRootValue) &&
272
- bucketRootValue[interfaces_js_1.$$streamMore]) {
273
+ bucketRootValue[constants_js_1.$$streamMore]) {
273
274
  // We expect exactly one streamable, we should not need to
274
275
  // `releaseUnusedIterators(rootBucket, rootBucketIndex, null)` here.
275
276
  const arr = bucketRootValue;
276
- const stream = arr[interfaces_js_1.$$streamMore];
277
+ const stream = arr[constants_js_1.$$streamMore];
277
278
  // Do the async iterable
278
279
  let stopped = false;
279
280
  const abort = (0, deferred_js_1.defer)();
@@ -331,7 +332,7 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
331
332
  return iterator;
332
333
  }
333
334
  const [ctx, result] = outputBucket(operationPlan.rootOutputPlan, rootBucket, rootBucketIndex, requestContext, [], rootBucket.store.get(operationPlan.variableValuesStep.id).at(0), outputDataAsString);
334
- return finalize(result, ctx, rootValue[interfaces_js_1.$$extensions] ?? undefined, outputDataAsString);
335
+ return finalize(result, ctx, rootValue[constants_js_1.$$extensions] ?? undefined, outputDataAsString);
335
336
  }
336
337
  if ((0, utils_js_1.isPromiseLike)(bucketPromise)) {
337
338
  return bucketPromise.then(output);
@@ -341,12 +342,12 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
341
342
  }
342
343
  }
343
344
  function establishOperationPlanFromEvent(event) {
344
- return (0, establishOperationPlan_js_1.establishOperationPlan)(event.schema, event.operation, event.fragments, event.variableValues, event.context, event.rootValue, event.planningTimeout);
345
+ return (0, establishOperationPlan_js_1.establishOperationPlan)(event.schema, event.operation, event.fragments, event.variableValues, event.context, event.rootValue, event.options);
345
346
  }
346
347
  /**
347
348
  * @internal
348
349
  */
349
- function grafastPrepare(args, options = {}) {
350
+ function grafastPrepare(args, options) {
350
351
  const { schema, contextValue: context, rootValue = Object.create(null),
351
352
  // operationName,
352
353
  // document,
@@ -356,11 +357,10 @@ function grafastPrepare(args, options = {}) {
356
357
  if (Array.isArray(exeContext) || "length" in exeContext) {
357
358
  return Object.assign(Object.create(bypassGraphQLObj), {
358
359
  errors: exeContext,
359
- extensions: rootValue[interfaces_js_1.$$extensions],
360
+ extensions: rootValue[constants_js_1.$$extensions],
360
361
  });
361
362
  }
362
363
  const { operation, fragments, variableValues } = exeContext;
363
- const planningTimeout = options.timeouts?.planning;
364
364
  let operationPlan;
365
365
  try {
366
366
  if (middleware != null) {
@@ -371,12 +371,12 @@ function grafastPrepare(args, options = {}) {
371
371
  variableValues,
372
372
  context: context,
373
373
  rootValue,
374
- planningTimeout,
375
374
  args,
375
+ options,
376
376
  }, establishOperationPlanFromEvent);
377
377
  }
378
378
  else {
379
- operationPlan = (0, establishOperationPlan_js_1.establishOperationPlan)(schema, operation, fragments, variableValues, context, rootValue, planningTimeout);
379
+ operationPlan = (0, establishOperationPlan_js_1.establishOperationPlan)(schema, operation, fragments, variableValues, context, rootValue, options);
380
380
  }
381
381
  }
382
382
  catch (error) {
@@ -388,13 +388,13 @@ function grafastPrepare(args, options = {}) {
388
388
  if (options.explain === true ||
389
389
  (options.explain && options.explain.includes("plan"))) {
390
390
  // Only build the plan once
391
- if (operationPlan[$$contextPlanCache] == null) {
392
- operationPlan[$$contextPlanCache] = operationPlan.generatePlanJSON();
391
+ if (operationPlan[constants_js_1.$$contextPlanCache] == null) {
392
+ operationPlan[constants_js_1.$$contextPlanCache] = operationPlan.generatePlanJSON();
393
393
  }
394
- rootValue[interfaces_js_1.$$extensions]?.explain?.operations.push({
394
+ rootValue[constants_js_1.$$extensions]?.explain?.operations.push({
395
395
  type: "plan",
396
396
  title: "Plan",
397
- plan: operationPlan[$$contextPlanCache],
397
+ plan: operationPlan[constants_js_1.$$contextPlanCache],
398
398
  });
399
399
  }
400
400
  const executionTimeout = options.timeouts?.execution ?? null;
@@ -408,6 +408,9 @@ function newIterator(abort) {
408
408
  [Symbol.asyncIterator]() {
409
409
  return this;
410
410
  },
411
+ async [Symbol.asyncDispose]() {
412
+ await this.return();
413
+ },
411
414
  push(v) {
412
415
  if (done) {
413
416
  // LOGGING: should we raise this as a bigger issue?
@@ -478,7 +481,7 @@ function newIterator(abort) {
478
481
  abort(e);
479
482
  for (const entry of pullQueue) {
480
483
  try {
481
- entry[0]({ done, value: undefined });
484
+ entry[1](e);
482
485
  }
483
486
  catch (e) {
484
487
  // ignore
@@ -493,21 +496,14 @@ async function processStream(requestContext, iterator, spec, outputDataAsString)
493
496
  /** Resolve this when finished */
494
497
  const whenDone = (0, deferred_js_1.defer)();
495
498
  let queue = null;
499
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
496
500
  let timeout = null;
497
- timeout;
498
501
  const _processQueue = (entries) => {
499
502
  const size = entries.length;
500
503
  const store = new Map();
501
504
  const polymorphicPathList = [];
502
505
  const iterators = [];
503
- let directLayerPlanChild = spec.outputPlan.layerPlan;
504
- while (directLayerPlanChild.parentLayerPlan !== spec.bucket.layerPlan) {
505
- const parent = directLayerPlanChild.parentLayerPlan;
506
- if (!parent) {
507
- throw new Error(`GrafastInternalError<f6179ee1-ace2-429c-8f30-8fe6cd53ed03>: Invalid heirarchy - could not find direct layerPlan child of ${spec.bucket.layerPlan}`);
508
- }
509
- directLayerPlanChild = parent;
510
- }
506
+ const directLayerPlanChild = (0, OutputPlan_js_1.getDirectLayerPlanChild)(spec.bucket.layerPlan, spec.outputPlan.layerPlan);
511
507
  const { id: listItemStepId, _isUnary: isUnary } = directLayerPlanChild.rootStep;
512
508
  for (const copyStepId of directLayerPlanChild.copyStepIds) {
513
509
  const executionValue = spec.bucket.store.get(copyStepId);
@@ -537,14 +533,15 @@ async function processStream(requestContext, iterator, spec, outputDataAsString)
537
533
  }
538
534
  // const childBucket = newBucket(directLayerPlanChild, noDepsList, store);
539
535
  // const childBucketIndex = 0;
540
- const rootBucket = (0, executeBucket_js_1.newBucket)({
536
+ const rootBucket = (0, executeBucket_js_1.newBucket)(spec.bucket, {
541
537
  layerPlan: directLayerPlanChild,
542
538
  size,
543
539
  store,
544
540
  flagUnion: 0,
545
541
  polymorphicPathList,
542
+ polymorphicType: null,
546
543
  iterators,
547
- }, spec.bucket.metaByMetaKey);
544
+ });
548
545
  const bucketPromise = (0, executeBucket_js_1.executeBucket)(rootBucket, requestContext);
549
546
  const output = () => {
550
547
  const promises = [];
@@ -675,14 +672,15 @@ function processSingleDeferred(requestContext, outputPlan, specs, asString) {
675
672
  }
676
673
  // const childBucket = newBucket(spec.outputPlan.layerPlan, noDepsList, store);
677
674
  // const childBucketIndex = 0;
678
- const rootBucket = (0, executeBucket_js_1.newBucket)({
675
+ const rootBucket = (0, executeBucket_js_1.newBucket)(null, {
679
676
  layerPlan: outputPlan.layerPlan,
680
677
  size,
681
678
  store,
682
679
  flagUnion: 0,
683
680
  polymorphicPathList,
681
+ polymorphicType: null,
684
682
  iterators,
685
- }, null);
683
+ });
686
684
  const bucketPromise = (0, executeBucket_js_1.executeBucket)(rootBucket, requestContext);
687
685
  const output = () => {
688
686
  const promises = [];
@@ -720,21 +718,26 @@ function processSingleDeferred(requestContext, outputPlan, specs, asString) {
720
718
  }
721
719
  }
722
720
  function processBatches(batchesByRequestTools, whenDone, asString) {
723
- // Key is only used for batching
724
- const promises = [];
725
- for (const [requestContext, batches] of batchesByRequestTools.entries()) {
726
- for (const [outputPlan, specs] of batches.entries()) {
727
- const promise = processSingleDeferred(requestContext, outputPlan, specs, asString);
728
- if ((0, utils_js_1.isPromiseLike)(promise)) {
729
- promises.push(promise);
721
+ try {
722
+ // Key is only used for batching
723
+ const promises = [];
724
+ for (const [requestContext, batches] of batchesByRequestTools.entries()) {
725
+ for (const [outputPlan, specs] of batches.entries()) {
726
+ const promise = processSingleDeferred(requestContext, outputPlan, specs, asString);
727
+ if ((0, utils_js_1.isPromiseLike)(promise)) {
728
+ promises.push(promise);
729
+ }
730
730
  }
731
731
  }
732
+ if (promises.length > 0) {
733
+ Promise.all(promises).then(() => whenDone.resolve(), (e) => whenDone.reject(e));
734
+ }
735
+ else {
736
+ whenDone.resolve();
737
+ }
732
738
  }
733
- if (promises.length > 0) {
734
- Promise.all(promises).then(() => whenDone.resolve(), (e) => whenDone.reject(e));
735
- }
736
- else {
737
- whenDone.resolve();
739
+ catch (e) {
740
+ whenDone.reject(e);
738
741
  }
739
742
  }
740
743
  function processBatchAsString() {
package/dist/step.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import type { GraphQLObjectType } from "graphql";
1
+ import { $$subroutine } from "./constants.js";
2
2
  import type { LayerPlan, LayerPlanReasonSubroutine } from "./engine/LayerPlan.js";
3
3
  import type { OperationPlan } from "./engine/OperationPlan.js";
4
- import type { AddDependencyOptions, DependencyOptions, ExecutionDetails, ExecutionEntryFlags, ExecutionResults, GrafastResultsList, JSONValue, PromiseOrDirect, StepOptimizeOptions, UnbatchedExecutionExtra } from "./interfaces.js";
5
- import { $$subroutine } from "./interfaces.js";
4
+ import type { AddDependencyOptions, AddUnaryDependencyOptions, DependencyOptions, ExecutionDetails, ExecutionEntryFlags, ExecutionResults, GrafastResultsList, JSONValue, PromiseOrDirect, StepOptimizeOptions, UnbatchedExecutionExtra } from "./interfaces.js";
6
5
  import type { __FlagStep, __ItemStep } from "./steps/index.js";
7
6
  declare function reallyAssertFinalized(plan: Step): void;
8
7
  export declare const assertFinalized: typeof reallyAssertFinalized;
@@ -105,6 +104,7 @@ export declare class Step<TData = any> {
105
104
  withLayerPlan<T>(callback: () => T): T;
106
105
  protected getStep(id: number): Step;
107
106
  protected getDepOptions<TStep extends Step = Step>(depId: number): DependencyOptions<TStep>;
107
+ protected _getDepOptions<TStep extends Step = Step>(depId: number): DependencyOptions<TStep>;
108
108
  protected getDep<TStep extends Step = Step>(_depId: number): TStep | __FlagStep<TStep>;
109
109
  protected getDep<TStep extends Step = Step>(_depId: number, throwOnFlagged: true): TStep;
110
110
  protected maybeGetDep<TStep extends Step = Step>(depId: number | null | undefined): TStep | __FlagStep<TStep> | null;
@@ -131,15 +131,45 @@ export declare class Step<TData = any> {
131
131
  */
132
132
  toStringMeta(): string | null;
133
133
  planJSONExtra(): Record<string, JSONValue | undefined> | undefined;
134
+ /**
135
+ * **IF IN DOUBT, USE `.addDependency()` INSTEAD!
136
+ *
137
+ * This **DANGEROUS** method allows you to create a reference to another
138
+ * step. A reference is like a dependency except it has no runtime impact -
139
+ * the data is not passed into execute. In general you should only add
140
+ * references to steps that you directly or indirectly depend on (e.g. an
141
+ * ancestor step) so that you may communicate with said step during
142
+ * `optimize` (for example). Sometimes it's acceptable to reference steps
143
+ * that you don't transitively depend on; in those cases you're permitted to
144
+ * pass an `allowIndirectReason` to explain to yourself and others why you
145
+ * are breaking these rules.
146
+ *
147
+ * @experimental
148
+ */
149
+ protected addRef(rawStep: Step, allowIndirectReason?: string | null): number | null;
150
+ /**
151
+ * Allows you to dereference a reference made via `addRef`. Will resolve to
152
+ * whatever that step is now (or null if not found). Note that referenced
153
+ * referenced steps may change to a new step instance due to lifecycle
154
+ * methods (e.g. deduplicate) or even to an entirely separate class
155
+ * altogether (e.g. due to optimize). References are not guaranteed to be
156
+ * honoured.
157
+ *
158
+ * @experimental
159
+ */
160
+ protected getRef(refIdx: number | null): Step | null;
134
161
  protected canAddDependency(step: Step): boolean;
162
+ protected _addDependency(options: AddDependencyOptions): number;
135
163
  protected addDependency(stepOrOptions: Step | AddDependencyOptions): number;
164
+ protected addDataDependency(stepOrOptions: Step | AddDependencyOptions): number;
165
+ protected addStrongDependency(stepOrOptions: Step | AddDependencyOptions): number;
136
166
  /**
137
167
  * Adds "unary" dependencies; in `execute({count, values})` you'll receive a
138
168
  * `values[index]` (where `index` is the return value of this function) with
139
169
  * `isBatch = false` so you can use the `values[index].value` property
140
170
  * directly.
141
171
  */
142
- protected addUnaryDependency(stepOrOptions: Step | AddDependencyOptions): number;
172
+ protected addUnaryDependency(stepOrOptions: Step | AddUnaryDependencyOptions): number;
143
173
  /**
144
174
  * Given a list of "peer" steps, return a list of these `peers` that are
145
175
  * equivalent to this step.
@@ -189,6 +219,10 @@ export declare class Step<TData = any> {
189
219
  */
190
220
  execute(details: ExecutionDetails): ExecutionResults<TData>;
191
221
  destroy(): void;
222
+ toRecord?(): Step;
223
+ toSpecifier?(): Step;
224
+ toTypename?(): Step<string>;
225
+ cursor?(): Step;
192
226
  }
193
227
  export declare abstract class UnbatchedStep<TData = any> extends Step<TData> {
194
228
  static $$export: {
@@ -196,7 +230,7 @@ export declare abstract class UnbatchedStep<TData = any> extends Step<TData> {
196
230
  exportName: string;
197
231
  };
198
232
  finalize(): void;
199
- execute({ indexMap, values, extra, }: ExecutionDetails): PromiseOrDirect<GrafastResultsList<TData>>;
233
+ execute({ indexMap, values, extra, }: ExecutionDetails): GrafastResultsList<TData>;
200
234
  abstract unbatchedExecute(extra: UnbatchedExecutionExtra, ...tuple: any[]): PromiseOrDirect<TData>;
201
235
  }
202
236
  export declare function isStep<TData = any>(step: unknown): step is Step<TData>;
@@ -222,15 +256,17 @@ export type ListLikeStep<TData extends [...Step[]] = [...Step[]]> = Step<{
222
256
  at<TKey extends keyof TData>(key: TKey): Step<TData[TKey]>;
223
257
  };
224
258
  export declare function isListLikeStep<TData extends [...Step[]] = [...Step[]]>(plan: Step): plan is ListLikeStep<TData>;
225
- export type PolymorphicStep = Step & {
226
- planForType(objectType: GraphQLObjectType): Step;
227
- };
228
- export declare function isPolymorphicStep(s: Step): s is PolymorphicStep;
229
259
  export interface ListCapableStep<TOutputData, TItemStep extends Step<TOutputData> = Step<TOutputData>> extends Step<ReadonlyArray<any>> {
230
260
  listItem(itemPlan: __ItemStep<this>): TItemStep;
231
261
  }
232
262
  export declare function isListCapableStep<TData, TItemStep extends Step<TData>>(plan: Step<ReadonlyArray<TData>>): plan is ListCapableStep<TData, TItemStep>;
233
263
  export declare function assertListCapableStep<TData, TItemStep extends Step<TData>>(plan: Step<ReadonlyArray<TData>>, pathDescription: string): asserts plan is ListCapableStep<TData, TItemStep>;
264
+ export declare function stepHasToSpecifier<TStep extends Step>($step: TStep): $step is TStep & {
265
+ toSpecifier(): Step;
266
+ };
267
+ export declare function stepHasToRecord<TStep extends Step>($step: TStep): $step is TStep & {
268
+ toRecord(): Step;
269
+ };
234
270
  export {
235
271
  /** @deprecated Use ExecutableStep instead */
236
272
  Step as ExecutableStep,