Navegador

navegador / docs / guide / graph-queries.md
1
# Graph Queries
2
3
## Raw Cypher passthrough
4
5
Every high-level command is built on Cypher queries against FalkorDB. You can drop to raw Cypher for anything the built-in commands don't cover:
6
7
```bash
8
navegador query "MATCH (f:Function) RETURN f.name, f.file LIMIT 10"
9
```
10
11
Results are printed as a table to stdout. Pipe with `--format json` if you need machine-readable output:
12
13
```bash
14
navegador query "MATCH (f:Function) RETURN f.name, f.file" --format json
15
```
16
17
!!! warning
18
`navegador query` executes writes as well as reads. Use `MATCH` / `RETURN` for inspection. Use `CREATE` / `MERGE` / `DELETE` only if you know what you're doing — there is no undo.
19
20
---
21
22
## Useful example queries
23
24
### Find all functions decorated with `@login_required`
25
26
```cypher
27
MATCH (d:Decorator {name: "login_required"})-[:DECORATES]->(f:Function)
28
RETURN f.name, f.file, f.line
29
ORDER BY f.file
30
```
31
32
### Find all functions in a specific file
33
34
```cypher
35
MATCH (file:File {path: "src/auth/service.py"})-[:CONTAINS]->(f:Function)
36
RETURN f.name, f.line, f.signature
37
```
38
39
### Find everything a function calls (two hops)
40
41
```cypher
42
MATCH (f:Function {name: "process_payment"})-[:CALLS*1..2]->(callee:Function)
43
RETURN DISTINCT callee.name, callee.file
44
```
45
46
### Find all callers of a function
47
48
```cypher
49
MATCH (caller:Function)-[:CALLS]->(f:Function {name: "validate_token"})
50
RETURN caller.name, caller.file
51
```
52
53
### Find all rules in a domain
54
55
```cypher
56
MATCH (d:Domain {name: "Payments"})<-[:BELONGS_TO]-(r:Rule)
57
RETURN r.name, r.severity, r.description
58
ORDER BY r.severity
59
```
60
61
### Find all concepts implemented by code in a file
62
63
```cypher
64
MATCH (file:File {path: "src/payments/processor.py"})-[:CONTAINS]->(f)
65
-[:ANNOTATES]-(c:Concept)
66
RETURN DISTINCT c.name, c.description
67
```
68
69
### Find all decisions that relate to a domain
70
71
```cypher
72
MATCH (d:Domain {name: "Infrastructure"})<-[:BELONGS_TO]-(dec:Decision)
73
RETURN dec.name, dec.status, dec.date, dec.rationale
74
ORDER BY dec.date DESC
75
```
76
77
### Find classes that inherit from a base class
78
79
```cypher
80
MATCH (child:Class)-[:INHERITS]->(parent:Class {name: "BaseProcessor"})
81
RETURN child.name, child.file
82
```
83
84
### Find the full inheritance chain for a class
85
86
```cypher
87
MATCH path = (c:Class {name: "StripeProcessor"})-[:INHERITS*]->(ancestor)
88
RETURN [node IN nodes(path) | node.name] AS hierarchy
89
```
90
91
### Find wiki pages that document a concept
92
93
```cypher
94
MATCH (wp:WikiPage)-[:DOCUMENTS]->(c:Concept {name: "Idempotency"})
95
RETURN wp.title, wp.url
96
```
97
98
### Find all functions annotated with a specific rule
99
100
```cypher
101
MATCH (r:Rule {name: "RequireIdempotencyKey"})-[:GOVERNS]->(f:Function)
102
RETURN f.name, f.file, f.line
103
```
104
105
### Find what a person is assigned to
106
107
```cypher
108
MATCH (p:Person {name: "Alice Chen"})<-[:ASSIGNED_TO]-(item)
109
RETURN labels(item)[0] AS type, item.name
110
```
111
112
---
113
114
## navegador stats
115
116
Get a high-level count of everything in the graph:
117
118
```bash
119
navegador stats
120
navegador stats --json
121
```
122
123
Output breakdown:
124
125
| Metric | What it counts |
126
|---|---|
127
| Repositories | `Repository` nodes |
128
| Files | `File` nodes |
129
| Classes | `Class` nodes |
130
| Functions + Methods | `Function` + `Method` nodes combined |
131
| Decorators | `Decorator` nodes |
132
| Imports | `Import` nodes |
133
| Domains | `Domain` nodes |
134
| Concepts | `Concept` nodes |
135
| Rules | `Rule` nodes |
136
| Decisions | `Decision` nodes |
137
| People | `Person` nodes |
138
| WikiPages | `WikiPage` nodes |
139
| Total edges | All relationship edges |
140
141
Use `--json` to feed stats into CI dashboards or coverage checks.
142

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button