SDK · Playground
Pick a recipe, hit Run to see the simulated output, or Open in StackBlitz to get a live Node.js environment with @unified-product-graph/sdk pre-installed and the recipe ready to edit and run.
Cookbook · Writing
Pass parent_id and you get both a node and the parent edge back in one call. Destructure the wrapped return shape.
Code
import { UPGClient } from '@unified-product-graph/sdk'
const upg = new UPGClient({ file: './product.upg' })
// 1. Create the parent.
const { node: persona } = await upg.nodes.create({
type: 'persona',
title: 'Busy Parent',
})
// 2. Create a child + auto-parent edge in one shot.
const { node: job, edge } = await upg.nodes.create({
type: 'job',
title: 'Find ten minutes to work out',
parent_id: persona.id,
})
console.log('node id:', job.id)
console.log('auto edge:', edge?.type, '→', edge?.id)Output
// click ▶ Run to see what this snippet would print locally