Skip to content

Fix visual Cypher query rendering for returned relationships#732

Open
slobodanmargetic988 wants to merge 1 commit intoCodeGraphContext:mainfrom
slobodanmargetic988:codex/fix-cypher-visualization-edges
Open

Fix visual Cypher query rendering for returned relationships#732
slobodanmargetic988 wants to merge 1 commit intoCodeGraphContext:mainfrom
slobodanmargetic988:codex/fix-cypher-visualization-edges

Conversation

@slobodanmargetic988
Copy link
Copy Markdown

Summary

  • render edges for raw Cypher visualizations when queries explicitly return relationships
  • support both explicit RETURN a, r, b results and Kuzu path objects from RETURN p
  • normalize Kuzu element ids into stable vis-network ids so nodes and edges connect correctly

Problem

cgc query --visual was rendering nodes but silently dropping edges for read-only graph queries.

Two common forms were affected:

  • MATCH (a)-[r]->(b) RETURN a, r, b LIMIT 50 --visual
  • MATCH p=(a)-[r]->(b) RETURN p LIMIT 50 --visual

The CLI help advertises this workflow, but the visualizer only converted returned dict/list values into nodes. It never converted returned relationship objects into edgesData, and path objects were treated as one opaque node with _nodes/_rels inside the tooltip.

Fix

This patch updates visualize_cypher_results(...) to:

  • unpack Kuzu path objects with _nodes and _rels
  • recognize explicit relationship dicts with _src / _dst
  • emit vis-network edges with from, to, label, and arrows
  • normalize Kuzu ids like {table, offset} into stable string ids so node/edge references match

The existing guardrail remains in place: we still do not infer edges when the query returns unrelated nodes without explicit relationships.

Verification

  • python3 -m py_compile src/codegraphcontext/cli/visualizer.py
  • locally verified that generated visualization HTML now contains non-empty edgesData for:
    • MATCH (a)-[r]->(b) RETURN a, r, b LIMIT 2
    • MATCH p=(a)-[r]->(b) RETURN p LIMIT 2

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 17, 2026

@slobodanmargetic988 is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant