MCPcopy Create free account
hub / github.com/codemix/graph / splitSteps

Method splitSteps

packages/graph/src/Steps.ts:5669–5707  ·  view source on GitHub ↗

* Split inner steps into fetch steps, filter steps, and mutation steps. * This allows proper scope injection between fetch and filter operations. * * - fetchSteps: Steps that create/traverse paths (FetchVertices, ShortestPath, etc.) * - filterSteps: FilterElements steps that come AFTER a

()

Source from the content-addressed store, hash-verified

5667 * FOREACH iteration variables.
5668 */
5669 private splitSteps(): {
5670 fetchSteps: Step<any>[];
5671 filterSteps: Step<any>[];
5672 mutationSteps: Step<any>[];
5673 } {
5674 const fetchSteps: Step<any>[] = [];
5675 const filterSteps: Step<any>[] = [];
5676 const mutationSteps: Step<any>[] = [];
5677
5678 // Find the last non-mutation step that's not a FilterElementsStep
5679 // All FilterElementsStep after that point go to filterSteps
5680 let lastFetchIndex = -1;
5681 for (let i = this.steps.length - 1; i >= 0; i--) {
5682 const step = this.steps[i];
5683 if (step instanceof SetStep || step instanceof DeleteStep) {
5684 continue; // Skip mutation steps
5685 }
5686 if (!(step instanceof FilterElementsStep)) {
5687 lastFetchIndex = i;
5688 break;
5689 }
5690 }
5691
5692 for (let i = 0; i < this.steps.length; i++) {
5693 const step = this.steps[i]!;
5694
5695 if (step instanceof SetStep || step instanceof DeleteStep) {
5696 mutationSteps.push(step);
5697 } else if (step instanceof FilterElementsStep && i > lastFetchIndex) {
5698 // FilterElementsStep after all fetch steps goes to filterSteps
5699 filterSteps.push(step);
5700 } else {
5701 // All other steps (including FilterElementsStep before fetch steps) go to fetchSteps
5702 fetchSteps.push(step);
5703 }
5704 }
5705
5706 return { fetchSteps, filterSteps, mutationSteps };
5707 }
5708
5709 public override clone(partial?: Partial<ForeachStepConfig>) {
5710 const { config, steps } = this;

Callers 1

traverseMethod · 0.95

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected