Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 2.04 KB

File metadata and controls

59 lines (42 loc) · 2.04 KB

Debugging

Call graph.info() at any time to inspect the state of the graph:

const info = graph.info();
Field Type Description
entityCounts Record<string, number> Number of entities stored per type.
cache.nodeCount number Number of nodes currently held in the internal node cache.
missingEntities `{ type: string; id: string number }[]`
orphanEntities `Record<string, (string number)[]>`

Example — a graph with bad data:

// sub2 has mainCategoryId: "cat99" which does not exist
// cat3 is loaded but no subcategory points to it

const info = graph.info();

info.missingEntities;
// [{ type: "mainCategory", id: "cat99" }]

info.orphanEntities;
// { mainCategory: ["cat3"] }

missingEntities and orphanEntities make it easy to spot data quality problems — broken foreign keys, incomplete data loads, or stale ids — without traversing the graph manually.

graph.schema()

Call graph.schema() to get a structural overview of the graph — which entity types are registered and how they are connected.

const schema = graph.schema();
Field Type Description
entities string[] Names of all registered entity types.
edges { from: string; to: string; bidirectional: boolean }[] All defined edges, including whether each is bidirectional.

Example:

const schema = graph.schema();

schema.entities;
// ["transaction", "subcategory", "mainCategory"]

schema.edges;
// [
//   { from: "transaction", to: "subcategory",  bidirectional: true },
//   { from: "subcategory", to: "mainCategory", bidirectional: true },
// ]