POST /query returns the relevant part of it next to the matching passages, so your model can answer “What team owns the service that failed?” when no single passage says so.
HydraDB builds the graph while it indexes your context. The named things are entities. One relationship between two of them is a triplet of source, relation, and target, such as Payments team, owns, billing service. Following relationships from one entity to the next is traversal; each step is a hop, and a question that needs two or more is multi-hop.
In this guide:
- Get relationships with your results: the
graph_contextfield, using a billing question as the example. - Turn the graph off: when you only need chunks.
- Where the relationships come from: extraction, declared links, and your own graph.
- Walk the items around one result: the Connected Subgraph endpoint.
- Put graph context in your prompt.
1. Get relationships with your results
graph_context is on by default, so this is an ordinary knowledge query. It sets mode: "thinking" because thinking mode does the most graph work; in "fast" mode the graph slice is shallower.
Query with graph context: Python, TypeScript, or cURL
Query with graph context: Python, TypeScript, or cURL
data payload of a response with graph context looks like this (chunks trimmed):What each field in graph_context means
Empty arrays mean no relationships were found for that query. That is not an error; there is no structure to show.
2. Turn the graph off
Setgraph_context: false when your code only reads chunks; the response gets smaller and the traversal is skipped. This takes effect only in "fast" mode (explicit, or "auto" routed to fast). "thinking" always includes the graph.
Direct factual lookups rarely need the graph. Questions about ownership, cause and effect, sequence, or dependencies usually do, and so does anything that needs to combine information across several chunks.
3. Where the relationships come from
- Extracted at ingestion: HydraDB reads each source, finds the entities and the relationships between them, and stores the triplets. A source is searchable at the
graph_creationstatus;completedmeans its graph work is done too, which is what full traversal needs. See Knowledge. - Declared by you: links between whole sources that belong together but whose text does not say so, set with
relations.idsat ingest. A query in thinking mode returns the linked text inadditional_context. Knowledge shows how. App sources also connect through fields such asthread_idandparent_id; see App Sources. - Supplied by you: Bring Your Own Graph replaces extraction for a source with the entities and relations you send. They appear in
graph_contextalongside extracted ones, taggedorigin: "byog".
4. Walk the items around one result
The graph also holds relations between items rather than between entities: a Slack reply and the message it answers, a page and the pages it links to, a comment and its ticket. Given one item’s id, Connected Subgraph follows those links, nearest items first, and returns the connected items up to the requested depth and result limit, with the relations among them: the rest of the thread, the hierarchy above and below, the items it references. Use it when one query result is not enough and you need what surrounds it. The dashboard’s Subgraph button opens the same view.5. Put graph context in your prompt
Pass the whole query result tobuild_string (Python) or buildString (TypeScript). After the chunks, the helper renders each path as one line per triplet: the source entity, the predicate, the target entity, and the relation’s context sentence. It reads query_paths, chunk_relations, and chunk_id_to_group_ids for you. How to Use API Results shows the full flow.
Related
- Query: how chunks and graph context are retrieved together
- Bring Your Own Graph: supply your own entities and relations instead of auto-extraction
- Knowledge: ingesting the documents the graph is built from, and linking the ones that belong together
- App Sources: threads, replies, and relations between app sources
- How to Use API Results: formatting graph context for model prompts
- Query API Reference: full graph response schema
- Connected Subgraph: everything connected to one item
