Quick start
Describe the shape, get the graph
Declare each node type and how it relates to the others. Stubgraph wires the references together and fills the fields from a seed. Cyclic relations and back-references resolve automatically.
Works as a library or on the command line. Output is plain JSON — drop it into tests, MSW handlers, Storybook, or a local mock server.
fixtures.ts
import { graph, seed } from "stubgraph";
const data = graph({
user: { id: "uuid", name: "name.full", posts: ["post"] },
post: { id: "uuid", title: "lorem.sentence", author: "user" },
}, { seed: 42, counts: { user: 5, post: 20 } });
// same seed -> identical graph, deterministic refs
data.user[0].posts[0].author.id === data.user[0].id;