Objective
Plain vector RAG retrieves one relevant passage, so it stumbles on questions that need to connect several facts: "which feature does the engineer who owns the billing service also work on?" That's a multi-hop question — it needs the relationships between entities, not just similar text. GraphRAG answers it by pairing semantic retrieval (find the right starting entity by meaning) with a graph walk (follow the edges). Here you'll build both surfaces in one engine: an embedded lookup table to find the entry point, and a Cypher knowledge graph to hop across. The same pattern works from any framework or a voice agent — see Use it from your agent at the end.
Step 1: Create a semantic entry-point index (SQL + vectors)
A small table maps natural-language descriptions to graph node names, so the agent can find where to start the walk by meaning.
CREATE TABLE IF NOT EXISTS recipe_graphrag_index (
node_id INTEGER PRIMARY KEY,
node_name TEXT, -- matches a node name in the graph
node_kind TEXT, -- 'person' | 'service' | 'feature'
blurb TEXT, -- description used for semantic match
embedding VECTOR(384)
);
Step 2: Seed the entry-point index
Describe each entity in plain language so a loosely-worded question can still find it.
INSERT INTO recipe_graphrag_index (node_id, node_name, node_kind, blurb) VALUES
(1,'Priya','person','Priya is a backend engineer who owns the billing and payments service.'),
(2,'Marco','person','Marco is a frontend engineer focused on the checkout user interface.'),
(3,'BillingService','service','The billing service handles invoices, subscriptions, and payment processing.'),
(4,'CheckoutUI','feature','The checkout UI is the page where customers enter payment details.'),
(5,'DunningFeature','feature','Dunning automatically retries failed payments and emails customers.');
Step 3: Embed the entry-point index
The embedding model runs in-database; this is how the agent maps a question to a starting node.
UPDATE recipe_graphrag_index SET embedding = EMBED(blurb);
Step 4: Find the starting node by meaning
Given "who handles failed payments?", retrieve the closest entity — the entry point for the graph walk.
SELECT node_name, node_kind, blurb,
COSINE_SIMILARITY(embedding, EMBED('who is responsible for charging customers and retrying failed payments?')) AS relevance
FROM recipe_graphrag_index
ORDER BY relevance DESC
LIMIT 2;
Step 5: Build the knowledge graph (Cypher)
Create the people, services, and features, and the edges between them — the structure RAG can't represent.
MERGE (priya:Person {name: 'Priya'})
MERGE (marco:Person {name: 'Marco'})
MERGE (billing:Service {name: 'BillingService'})
MERGE (checkout:Feature {name: 'CheckoutUI'})
MERGE (dunning:Feature {name: 'DunningFeature'})
MERGE (priya)-[:OWNS]->(billing)
MERGE (marco)-[:OWNS]->(checkout)
MERGE (billing)-[:HAS_FEATURE]->(dunning)
MERGE (billing)-[:INTEGRATES_WITH]->(checkout)
MERGE (marco)-[:CONTRIBUTES_TO]->(dunning);