Section 3.3Source:
server/src/graph/GraphQuery.tsGraph Query Layer
A semantic, read-only API layer providing typed single-hop lookups for callers, callees, importers, subclasses, and dependency sets.
Source:
server/src/graph/GraphQuery.tsSemantic Query Methods
GraphQuery wraps raw map accesses with type-safe, semantic lookup methods that return hydrated GraphNode[] objects:
| Method | Edge Direction | Filter Kind | Target Node Kind | Description |
|---|---|---|---|---|
| getCallers(nodeId) | Incoming | "calls" | symbol | Returns all functions/methods calling this symbol. |
| getCallees(nodeId) | Outgoing | "calls" | symbol | Returns all functions/methods called by this symbol. |
| getImporters(nodeId) | Incoming | "imports" | file | Returns all files that import this file or symbol. |
| getImportedFiles(nodeId) | Outgoing | "imports" | file | Returns internal source files imported by this file. |
| getPackageDependencies(nodeId) | Outgoing | "imports" | dependency | Returns external npm packages imported by this file. |
| getBaseClasses(nodeId) | Outgoing | "extends" | symbol | Returns the superclass extended by this class. |
| getSubclasses(nodeId) | Incoming | "extends" | symbol | Returns classes that extend this base class. |
| getImplementedInterfaces(nodeId) | Outgoing | "implements" | symbol | Returns interfaces implemented by this class. |
| getImplementations(nodeId) | Incoming | "implements" | symbol | Returns classes implementing this interface. |
| getDependentNodes(nodeId) | Outgoing | All structural | Any | Returns all direct dependencies across all 5 structural types. |
| getDependents(nodeId) | Incoming | All structural | Any | Returns all nodes directly dependent on this node. |
Hydration & Defensive Node-Kind Checks
Every derived query explicitly validates node.kind before returning. For example,getCallers() guarantees it will only return SymbolNode objects:
server/src/graph/GraphQuery.ts
123456789101112131415getCallers(nodeId: string): GraphNode[] { const callers: GraphNode[] = []; for (const edgeId of this.graph.incomingEdges.get(nodeId) || []) { const edge = this.graph.edges.get(edgeId); if (!edge || edge.relationshipKind !== "calls") continue; const callerNode = this.graph.nodes.get(edge.sourceId); if (callerNode && callerNode.kind === "symbol") { callers.push(callerNode); } } return callers; }