Skip to content

Add JSON GraphRenderer + !graph --format flag#231

Merged
jogrogan merged 1 commit into
mainfrom
jogrogan/jsonRender
Jun 8, 2026
Merged

Add JSON GraphRenderer + !graph --format flag#231
jogrogan merged 1 commit into
mainfrom
jogrogan/jsonRender

Conversation

@jogrogan

@jogrogan jogrogan commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a second GraphRenderer implementation — JsonGraphRenderer — alongside the
existing Mermaid renderer, and exposes renderer selection through the !graph CLI
command via a new --format flag. This gives programmatic consumers a structured,
parse-friendly view of the same pipeline topology the Mermaid renderer draws, without
scraping Mermaid text.

Builds on the pluggable graph SPI introduced in #222. No changes to the graph data
model (PipelineGraph / GraphNode / GraphEdge) or providers — this is purely a new
renderer plus CLI plumbing.

JSON is more easily sent over the wire and rendered by web UIs.

What's included

hoptimator-graph

  • New JsonGraphRenderer (format() == "json") that serializes a PipelineGraph to a
    stable JSON document. Registered via META-INF/services so it's discovered through
    GraphService exactly like the Mermaid renderer.
  • Adds a jackson-databind dependency (used for correct escaping / tree building).

hoptimator-cli

  • !graph <identifier> [--depth N] [--format mermaid|json]. Default remains
    mermaid
    — existing behavior and integration scripts are unchanged. --format
    dispatches through GraphService.render(graph, format) to the matching SPI.
  • Unsupported formats are rejected with the list of available formats (validated against
    GraphService.availableFormats()).
  • The degenerate-resource warning (a Mermaid %% comment) is now only emitted for
    Mermaid output, so JSON output stays valid/parseable.

Docs

  • docs/user-guide/sql-cli.md: documents --format with a JSON example.
  • docs/extending/index.md: notes that both Mermaid and JSON renderers now ship.

JSON format

{ "root": "<GraphNode.id of the focal node>", "orientation": "LR" | "TD",          // TD when the root is a LogicalTable, else LR "nodes": [
   { "id", "kind", "displayName", ...kind-specific fields },
   // PIPELINE:       name, jobKind?, engine?, executionMode?
   // VIEW:           name, materialized
   // LOGICAL_TABLE:  name, tiers { tier -> database }
   // TRIGGER:        name, schedule?, paused, jobTemplateName?, containerName?
   // EXTERNAL:       database, path[] ], "edges": [ { "from", "to", "type" } ]  // includes OWNER_OF
}

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Code Coverage

Overall Project 84.49% -0.04% 🟢
Files changed 94.97% 🟢

File Coverage
JsonGraphRenderer.java 94.97% -5.03% 🟢

@jogrogan jogrogan merged commit 4f2728c into main Jun 8, 2026
1 check passed
@jogrogan jogrogan deleted the jogrogan/jsonRender branch June 8, 2026 21:05
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.

2 participants