Learn how to query the Engineering Knowledge Graph using natural language and APIs
The Engineering Knowledge Graph provides multiple ways to query infrastructure data: natural language queries, REST API endpoints, and direct Cypher queries. This guide covers all query methods.
Who owns the payment service?Response:The payment-service is owned by the payments-team.Team Lead: Frank WilsonSlack: #paymentsPagerDuty: payments-oncall
from graph.query import QueryEnginefrom graph.storage import GraphStoragestorage = GraphStorage()query_engine = QueryEngine(storage)# Get downstream dependenciesresult = query_engine.downstream( node_id="service:order-service", max_depth=10, edge_types=['depends_on', 'uses', 'calls'])for dep in result: print(f"{dep['name']} ({dep['type']}) - distance {dep['distance']}")
Method Signature:
graph/query.py
def downstream( self, node_id: str, max_depth: int = 10, edge_types: List[str] = None) -> List[Dict[str, Any]]: """ Get all transitive dependencies (what this node depends on). Args: node_id: Starting node ID (format: "type:name") max_depth: Maximum traversal depth to prevent infinite loops (default: 10) edge_types: Optional list of edge types to follow (e.g., ['uses', 'calls']) Returns: List of dependency nodes with distance from start """
def blast_radius(self, node_id: str, max_depth: int = 10) -> Dict[str, Any]: """ Full impact analysis - upstream + downstream + affected teams. Args: node_id: Starting node ID max_depth: Maximum traversal depth Returns: Dict with keys: - center_node: The starting node - upstream_dependencies: What depends on this - downstream_dependencies: What this depends on - affected_teams: Teams that own affected components - total_affected_nodes: Total number of affected nodes - summary: Human-readable summary """
from graph.storage import GraphStoragestorage = GraphStorage()# Execute custom Cypher queryquery = """MATCH (s:service)-[:USES]->(db)WHERE db.type IN ['database', 'cache']RETURN s.name as service, db.name as database, db.type as db_typeORDER BY service"""results = storage.execute_cypher(query)for record in results: print(f"{record['service']} uses {record['database']} ({record['db_type']})")