@typedb/graph-utils
v3.7.0
Published
TypeDB graph utils
Readme
Graph visualisation with TypeDB (TypeScript)
A utility library to construct graph structures from TypeQL conceptRows query results.
Install
pnpm installBuild
pnpm run buildUsing the library
The library provides three main exports:
constructGraphFromRowsResult(response)— converts aConceptRowsQueryResponse(from@typedb/driver-http) into aDataGraph, a structured representation of the vertices and constraints in the query result.TypeDBAnswerConverter— an interface you implement to define how each constraint type (e.g.isa,has,links,sub) is handled.convertLogicalGraphWith(dataGraph, converter)— walks aDataGraphand calls the appropriate method on your converter for each constraint.
Example usage
import { constructGraphFromRowsResult, convertLogicalGraphWith, TypeDBAnswerConverter } from "typedb-visualizer-tutorial";
// 1. Run a query against TypeDB via the HTTP API with includeQueryStructure: true
const response: ConceptRowsQueryResponse = /* ... */;
// 2. Build a DataGraph from the response
const structuredAnswers = new StructuredAnswersBuilder().build(rowsResult);
// 3. Implement TypeDBAnswerConverter and walk the graph
const graphBuilder: AbstractGraphBuilder = /* your implementation */;
graphBuilder.build(dataGraph);A complete working example using Sigma.js for browser visualisation is in example/.
Releases
Released versions of @typedb/graph-utils are published to npmjs.org. Maintainers creating a release should follow the procedure in AGENTS.md.
Snapshot builds are published to Cloudsmith.
