(
query: (g: GraphTraversal<TSchema>) => Traversal<TSchema, TPath>,
)
| 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"]) { |
no test coverage detected