SDK Guide
Implementing an Adapter
How to map an external source (Notion, Linear, GitHub, Markdown) into a UPGDocument using the resolver helpers in the core package.
The adapter pattern
An adapter converts an external source (Notion, Linear, GitHub, Markdown) into a UPGDocument. The @unified-product-graph/adapters package ships reference implementations for all four. The pattern is: parse the source into raw entities, map each to a UPGEntityType using getDomainIdForType and the type catalog, use resolveContainmentEdge for parent–child relationships, fall back to node_informs_node for unresolvable cross-entity relationships.
resolveContainmentEdge is the strict resolver. If the (parent_type, child_type) pair is registered in UPG_EDGE_PAIR_MAP, it returns the canonical edge type. If not, it returns null — that signals the caller to use the polymorphic fallback rather than inventing an edge type.
import {
resolveContainmentEdge,
getDomainIdForType,
UPG_EDGE_CATALOG,
} from '@unified-product-graph/core'
function buildEdge(parentType: string, childType: string) {
const edgeType = resolveContainmentEdge(parentType, childType)
if (edgeType) return { type: edgeType }
// Fall back to polymorphic informational edge
return { type: 'node_informs_node' }
}