Querying with Cypher
Use Cypher query syntax to explore resources and relationships in the knowledge graph.
Query Endpoint
curl -X POST http://localhost:8080/api/v1/graph/query \
-H "Content-Type: application/json" \
-d '{"query": "MATCH (n) RETURN n LIMIT 10"}'Common Patterns
Count resources by type
MATCH (n)
WHERE n.type IS NOT NULL
RETURN n.type, count(n) AS cnt
ORDER BY cnt DESCFind dependencies of a resource
MATCH (n {id: "my-rds-instance"})-[r:DEPENDS_ON]->(m)
RETURN m.name, m.type, type(r)Blast radius analysis
// What depends on this database?
MATCH (n {id: "db-primary"})<-[:DEPENDS_ON*1..3]-(m)
RETURN DISTINCT m.name, m.typeFind untagged resources
MATCH (n)
WHERE n.type IS NOT NULL
AND (n.tags IS NULL OR size(n.tags) = 0)
RETURN n.name, n.type, n.providerResources by provider
MATCH (n)
WHERE n.provider = "aws"
RETURN n.type, count(n)
ORDER BY count(n) DESCParameterized Queries
Pass parameters to prevent injection:
curl -X POST http://localhost:8080/api/v1/graph/query \
-H "Content-Type: application/json" \
-d '{
"query": "MATCH (n {type: $type}) RETURN n",
"params": {"type": "aws.ec2.instance"}
}'Performance
Queries without
LIMIT clauses can return large result sets. Always add a limit when exploring: MATCH (n) RETURN n LIMIT 100.Graph Traversal API
For programmatic traversal without writing Cypher, use the traverse endpoint or the topology API:
# Traverse from a resource (max depth 3)
# Via API: graph.Traverse(ctx, startID, "outgoing", edgeTypes, 3)
# Get full topology for a scope
curl http://localhost:8080/api/v1/graph/topology/prod-aws