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 · Reading
Follow typed edges to assemble a multi-hop view in a few lines.
Code
import { UPGClient } from '@unified-product-graph/sdk'
const upg = new UPGClient({ file: './product.upg' })
const { nodes: personas } = await upg.nodes.list({ type: 'persona' })
for (const persona of personas) {
const pursues = await upg.edges.list({
source: persona.id,
type: 'persona_pursues_job',
})
for (const edge of pursues) {
const job = await upg.nodes.get(edge.target)
const features = await upg.edges.list({
target: edge.target,
type: 'feature_addresses_job',
})
console.log(
`${persona.title} → ${job?.title} (${features.length} features)`,
)
}
}Output
// click ▶ Run to see what this snippet would print locally