Navegador

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

Keyboard Shortcuts

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