MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / query_graph

Function query_graph

src/codegraphcontext/cli/main.py:3017–3037  ·  view source on GitHub ↗

Execute a custom Cypher query on the code graph. Examples: cgc query "MATCH (f:Function) RETURN f.name LIMIT 10" cgc query "MATCH (c:Class)-[:CONTAINS]->(m) RETURN c.name, count(m)" cgc query "MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 50" --visual

(
    ctx: typer.Context,
    query: str = typer.Argument(..., help="Cypher query to execute (read-only)"),
    visual: bool = typer.Option(False, "--visual", "--viz", "-V", help="Show results as interactive graph visualization"),
    context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
)

Source from the content-addressed store, hash-verified

3015
3016@app.command("query")
3017def query_graph(
3018 ctx: typer.Context,
3019 query: str = typer.Argument(..., help="Cypher query to execute (read-only)"),
3020 visual: bool = typer.Option(False, "--visual", "--viz", "-V", help="Show results as interactive graph visualization"),
3021 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
3022):
3023 """
3024 Execute a custom Cypher query on the code graph.
3025
3026 Examples:
3027 cgc query "MATCH (f:Function) RETURN f.name LIMIT 10"
3028 cgc query "MATCH (c:Class)-[:CONTAINS]->(m) RETURN c.name, count(m)"
3029 cgc query "MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 50" --visual
3030 """
3031 _load_credentials()
3032
3033 # Check if visual mode is enabled
3034 if check_visual_flag(ctx, visual):
3035 cypher_helper_visual(query, context)
3036 else:
3037 cypher_helper(query, context)
3038
3039# Keep old 'cypher' as alias for backward compatibility
3040@app.command("cypher", hidden=True)

Callers

nothing calls this directly

Calls 4

_load_credentialsFunction · 0.85
check_visual_flagFunction · 0.85
cypher_helper_visualFunction · 0.85
cypher_helperFunction · 0.85

Tested by

no test coverage detected