MCPcopy Index your code
hub / github.com/codemix/graph / query

Method query

packages/graph/src/AsyncGraph.ts:91–110  ·  view source on GitHub ↗
(
    query: (g: GraphTraversal<TSchema>) => Traversal<TSchema, TPath>,
  )

Source from the content-addressed store, hash-verified

89 }
90
91 public async *query<const TPath>(
92 query: (g: GraphTraversal<TSchema>) => Traversal<TSchema, TPath>,
93 ): AsyncIterable<TPath> {
94 const traversal = query(new GraphTraversal(this.#graph));
95 // Steps have custom toJSON methods, so we use JSON serialization
96 const steps = jsonClone(traversal.steps) as unknown as StepJSON[];
97
98 const results = this.#config.transport({
99 "@type": "AsyncQuery",
100 steps,
101 });
102
103 for await (const result of results) {
104 if (result != null && "@type" in result) {
105 yield this.instantiateResult(result) as TPath;
106 } else {
107 yield result as TPath;
108 }
109 }
110 }
111
112 protected instantiateResult<TPath>(result: TransportableValue): TPath {
113 switch (result["@type"]) {

Callers 1

AsyncGraph.test.tsFile · 0.45

Calls 3

instantiateResultMethod · 0.95
jsonCloneFunction · 0.85
queryFunction · 0.50

Tested by

no test coverage detected