grafast 0.1.1-beta.12 → 0.1.1-beta.13

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.
@@ -1118,6 +1118,7 @@ class OperationPlan {
1118
1118
  // PERF: this should be handled in the parent?
1119
1119
  const parentStep = this.stepTracker.getStepById(rawParentStep.id);
1120
1120
  const previousStepCount = this.stepTracker.stepCount;
1121
+ const previousSideEffectStep = layerPlan.latestSideEffectStep;
1121
1122
  if (this.loc !== null)
1122
1123
  this.loc.push(`planField(${path.join(".")})`);
1123
1124
  try {
@@ -1185,6 +1186,7 @@ class OperationPlan {
1185
1186
  }
1186
1187
  try {
1187
1188
  this.stepTracker.purgeBackTo(previousStepCount);
1189
+ layerPlan.latestSideEffectStep = previousSideEffectStep;
1188
1190
  }
1189
1191
  catch (e2) {
1190
1192
  console.error(`Cleanup error occurred whilst trying to recover from field planning error: ${e2.stack}`);
package/dist/step.js CHANGED
@@ -110,23 +110,49 @@ class ExecutableStep extends BaseStep {
110
110
  this.implicitSideEffectStep = null;
111
111
  this.hasSideEffects ??= false;
112
112
  let hasSideEffects = false;
113
+ const stepTracker = this.layerPlan.operationPlan.stepTracker;
113
114
  Object.defineProperty(this, "hasSideEffects", {
114
115
  get() {
115
116
  return hasSideEffects;
116
117
  },
117
118
  set(value) {
118
- if (this.id ===
119
- this.layerPlan.operationPlan.stepTracker.stepCount - 1) {
119
+ /**
120
+ * If steps were created after this step, an this step doesn't depend
121
+ * on them, then it's no longer safe to change hasSideEffects.
122
+ */
123
+ let nonDependentSteps = null;
124
+ const maxStepId = stepTracker.stepCount - 1;
125
+ if (this.id === maxStepId) {
126
+ // All good - no more steps were created
127
+ }
128
+ else {
129
+ // If the step created them during initialization and is dependent on
130
+ // them, that's fine too.
131
+ for (let id = this.id + 1; id <= maxStepId; id++) {
132
+ const step = stepTracker.getStepById(id);
133
+ if ((0, utils_js_1.stepADependsOnStepB)(this, step))
134
+ continue;
135
+ if (nonDependentSteps === null) {
136
+ nonDependentSteps = [step];
137
+ }
138
+ else {
139
+ nonDependentSteps.push(step);
140
+ }
141
+ }
142
+ }
143
+ if (nonDependentSteps === null) {
120
144
  hasSideEffects = value;
121
145
  if (value === true) {
122
146
  this.layerPlan.latestSideEffectStep = this;
123
147
  }
124
148
  else if (value !== true && hasSideEffects === true) {
125
- throw new Error(`Cannot mark a step has having no side effects after having set it to have side effects.`);
149
+ throw new Error(`Cannot mark ${this} as having no side effects after having set it to have side effects.`);
126
150
  }
127
151
  }
128
152
  else {
129
- throw new Error("You must mark a step as having side effects immediately after creating it, before any other steps are created.");
153
+ throw new Error(`Attempted to mark ${this} as having side effects, but other non-dependent steps (${nonDependentSteps
154
+ .map(String)
155
+ .join(", ")}) have already been created.`);
130
156
  }
131
157
  },
132
158
  enumerable: true,
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "0.1.1-beta.12";
1
+ export declare const version = "0.1.1-beta.13";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // This file is autogenerated by /scripts/postversion.mjs
5
- exports.version = "0.1.1-beta.12";
5
+ exports.version = "0.1.1-beta.13";
6
6
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grafast",
3
- "version": "0.1.1-beta.12",
3
+ "version": "0.1.1-beta.13",
4
4
  "description": "Cutting edge GraphQL planning and execution engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",