Is your feature request related to a problem? Please describe.
Current AST tooling focuses on extracting individual symbols (nodes) but does not provide a way to explore the relationships between them (edges). When working with real codebases, it’s often more important to understand how functions depend on each other than to simply list them. Without graph‑style queries, it’s difficult to answer questions like “Who calls this function?”, “What is the full call chain?”, or “Which functions are unused?”
Describe the solution you'd like
Add support for querying the AST using graph query languages such as Cypher, SPARQL, or GraphQL.
By exposing the AST as a graph—functions as nodes, calls as edges—developers could run structural queries, build call graphs, and analyze dependencies directly.
Describe alternatives you've considered
- Manually walking the AST and building a call graph in custom code
- Using external tools like
ast-grep or static analyzers, which still don’t provide graph‑query semantics
- Exporting AST data into a separate graph database and querying it there (adds unnecessary complexity)
Additional context
Example Code
def load_data():
return fetch_from_db()
def fetch_from_db():
return parse_record("raw")
def parse_record(x):
return x.upper()
def main():
data = load_data()
print(data)
Dependency chain: main → load_data → fetch_from_db → parse_record
Graph Query Examples
When a user needs to find all callers of parse_record:
Cypher Examples
MATCH (caller)-[:CALLS]->(callee {name: "parse_record"})
RETURN caller;
SPARQL Examples
PREFIX code: <http://example.com/code#>
SELECT ?caller
WHERE {
?caller code:calls ?callee .
?callee code:name "parse_record" .
}
GraphQL API Examples
query {
functions(where: { calls: { name: "parse_record" } }) {
name
}
}
Use Cases
| Query |
Purpose |
Which functions does load_data call? |
Inspect outgoing edges (dependencies). |
Which functions call parse_record? |
Reverse edges to find dependents. |
Show the full call chain starting from main() |
Traverse the graph (DFS/BFS). |
| Which functions are leaf nodes? |
Identify functions with no outgoing calls. |
| Which functions are unused? |
Identify nodes with no incoming edges. |
Why This Matters
- Enables richer static analysis
- Supports knowledge‑graph workflows
- Helps with refactoring, dead‑code detection, and architecture mapping
- Aligns with modern developer expectations around structural search
Is your feature request related to a problem? Please describe.
Current AST tooling focuses on extracting individual symbols (nodes) but does not provide a way to explore the relationships between them (edges). When working with real codebases, it’s often more important to understand how functions depend on each other than to simply list them. Without graph‑style queries, it’s difficult to answer questions like “Who calls this function?”, “What is the full call chain?”, or “Which functions are unused?”
Describe the solution you'd like
Add support for querying the AST using graph query languages such as Cypher, SPARQL, or GraphQL.
By exposing the AST as a graph—functions as nodes, calls as edges—developers could run structural queries, build call graphs, and analyze dependencies directly.
Describe alternatives you've considered
ast-grepor static analyzers, which still don’t provide graph‑query semanticsAdditional context
Example Code
Dependency chain:
main → load_data → fetch_from_db → parse_recordGraph Query Examples
When a user needs to find all callers of
parse_record:Cypher Examples
SPARQL Examples
GraphQL API Examples
Use Cases
load_datacall?parse_record?main()Why This Matters