CodeGraph/docs
Section 3.3

Graph 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.ts

Semantic Query Methods

GraphQuery wraps raw map accesses with type-safe, semantic lookup methods that return hydrated GraphNode[] objects:

MethodEdge DirectionFilter KindTarget Node KindDescription
getCallers(nodeId)Incoming"calls"symbolReturns all functions/methods calling this symbol.
getCallees(nodeId)Outgoing"calls"symbolReturns all functions/methods called by this symbol.
getImporters(nodeId)Incoming"imports"fileReturns all files that import this file or symbol.
getImportedFiles(nodeId)Outgoing"imports"fileReturns internal source files imported by this file.
getPackageDependencies(nodeId)Outgoing"imports"dependencyReturns external npm packages imported by this file.
getBaseClasses(nodeId)Outgoing"extends"symbolReturns the superclass extended by this class.
getSubclasses(nodeId)Incoming"extends"symbolReturns classes that extend this base class.
getImplementedInterfaces(nodeId)Outgoing"implements"symbolReturns interfaces implemented by this class.
getImplementations(nodeId)Incoming"implements"symbolReturns classes implementing this interface.
getDependentNodes(nodeId)OutgoingAll structuralAnyReturns all direct dependencies across all 5 structural types.
getDependents(nodeId)IncomingAll structuralAnyReturns 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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
getCallers(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; }