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

Method traverse

packages/graph/src/Steps.ts:7338–7382  ·  view source on GitHub ↗
(
    source: GraphSource<any>,
    input: Iterable<TraversalPath<any, any, any>>,
    _context?: QueryContext,
  )

Source from the content-addressed store, hash-verified

7336 }
7337
7338 public *traverse(
7339 source: GraphSource<any>,
7340 input: Iterable<TraversalPath<any, any, any>>,
7341 _context?: QueryContext,
7342 ): IterableIterator<TraversalPath<any, any, any>> {
7343 const { procedureName, arguments: args, yieldItems } = this.config;
7344
7345 for (const path of input) {
7346 this.traversed++;
7347
7348 // Resolve arguments
7349 const resolvedArgs = args.map((arg) => resolveConditionValue(path, arg));
7350
7351 // Create procedure context - pass source as graph (it implements GraphSource)
7352 const context = {
7353 graph: source,
7354 path,
7355 functionRegistry,
7356 };
7357
7358 // Invoke the procedure
7359 const results = procedureRegistry.invoke(procedureName, resolvedArgs, context);
7360
7361 for (const record of results) {
7362 // If no YIELD specified, bind all columns from the result
7363 if (!yieldItems || yieldItems.length === 0) {
7364 // For standalone CALL without YIELD, just pass through the path
7365 this.emitted++;
7366 yield path;
7367 // Only yield one row per input for standalone calls
7368 break;
7369 }
7370
7371 // Create a new path with yielded columns bound
7372 let newPath = path;
7373 for (const item of yieldItems) {
7374 const value = record[item.name];
7375 const bindName = item.alias ?? item.name;
7376 newPath = newPath.with(value, [bindName]);
7377 }
7378 this.emitted++;
7379 yield newPath;
7380 }
7381 }
7382 }
7383
7384 public clone(partial?: Partial<CallStepConfig>): CallStep {
7385 return new CallStep({

Callers

nothing calls this directly

Calls 4

resolveConditionValueFunction · 0.85
withMethod · 0.80
mapMethod · 0.45
invokeMethod · 0.45

Tested by

no test coverage detected