TypeScript SDK
Installation
Section titled “Installation”npm install @graphdb-labs/sdkInitialization
Section titled “Initialization”import { GraphDB } from "@graphdb-labs/sdk";
// SaaS (API key via edge-gateway)const graphdb = new GraphDB({ apiKey: process.env.GRAPHDB_API_KEY, graphId: "main",});
// Local dev (graphdb dev running at localhost:8787)const graphdb = new GraphDB({ baseUrl: "http://localhost:8787", tenantId: "dev-tenant", graphId: "main",});Graph management
Section titled “Graph management”const project = await graphdb.projects.create({ name: "My Project", slug: "my-project",});
const graph = await graphdb.graphs.create(project.id, { name: "main", environment: "production",});Schema definition
Section titled “Schema definition”await graphdb.schema.createNodeType(graph.id, { typeName: "Document", fieldDefs: [ { name: "title", type: "string", required: true }, ],});
await graphdb.schema.createEdgeType(graph.id, { typeName: "HAS_CHUNK", fromType: "Document", toType: "Chunk",});Node & edge CRUD
Section titled “Node & edge CRUD”const node = await graphdb.nodes.create(graph.id, { id: "doc_1", type: "Document", properties: { title: "Refund Policy" },});
const edge = await graphdb.edges.create(graph.id, { fromNode: "doc_1", toNode: "chunk_1", type: "HAS_CHUNK",});Traversal
Section titled “Traversal”const result = await graphdb.traverse(graph.id, { startNodeId: "doc_1", maxDepth: 2, edgeTypes: ["HAS_CHUNK"],});
console.log(result.nodes); // TraversalNode[]console.log(result.edges); // TraversalEdge[]Agentic RAG query
Section titled “Agentic RAG query”const context = await graphdb.agenticQuery(graph.id, { queryVector: await yourEmbedFn(userQuestion), expandVia: "HAS_CHUNK", depth: 1, topK: 5,});
// Feed context.context to your LLM