Load nodes & relationships
# grade this stage (from your course directory)
npx theinference test --stage load-the-graph --watchBring the graph to life. Read the two JSON files into typed records and build the master lookups nodeById and relById. This is the GraphStore constructor in disguise — the foundation every later chapter builds on.
Implement GraphStore.fromJson and the constructor
Parse the raw arrays into Node[] / Relationship[], index them by id, and report counts. The load CLI command prints { nodeCount, relCount, sample }, where sample is the full record for The Matrix (node id 66).
export class GraphStore {
readonly nodeById = new Map<number, Node>();
readonly relById = new Map<number, Relationship>();
constructor(nodes: Node[], rels: Relationship[]) {
for (const n of nodes) this.nodeById.set(n.id, n);
for (const r of rels) this.relById.set(r.id, r);
// (later chapters add adjacency + indexes here)
}
static fromJson(nodesJson: unknown, relsJson: unknown): GraphStore {
return new GraphStore(nodesJson as Node[], relsJson as Relationship[]);
}
}
your_program.sh load {fixture}/fixtures/data/nodes.json {fixture}/fixtures/data/relationships.json
# prints canonicalized JSON: {"nodeCount":87,"relCount":113,"sample":{...The Matrix...}}
Process mode, stdout_json_match: your printed JSON is deep-compared to fixtures/expected.json. Counts must be exact (87 / 113); the sampled record must deep-equal (object keys are compared as sets, so key order doesn't matter — print through canonicalizeValue).
released: 1999 must stay an integer, and roles: ['Neo'] must stay a string[] — don't stringify arrays or coerce numbers to strings. Property types are graded explicitly in the next step.