Skip to content

fix: render graph view correctly with nested @normalize nodes#402

Merged
raphael-istari merged 1 commit intomainfrom
399-render-graph-view-with-normalized-nodes
Jan 21, 2026
Merged

fix: render graph view correctly with nested @normalize nodes#402
raphael-istari merged 1 commit intomainfrom
399-render-graph-view-with-normalized-nodes

Conversation

@raphael-istari
Copy link
Copy Markdown
Contributor

@raphael-istari raphael-istari commented Jan 21, 2026

Fixes #399

handle the case of uid is an array after normalized query (and debug mode adding uid at every level)

Checklist

  • Code compiles correctly and linting passes locally

handle the case of uid  is an array after normalized query (and debug mode adding uid at every level)
@matthewmcneely matthewmcneely changed the title fix: Fixes #399 Render Graph view with nested @normalize nodes fix: render graph view correctly with nested @normalize nodes Jan 21, 2026
// uid, so we need to assign them one.
// When using @normalize with debug mode, uid can be an array - use first element.
const rawUid = obj.node.uid
const uid = Array.isArray(rawUid) ? rawUid[0] : rawUid || uuid()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphael-istari By just taking the first uid, are we guaranteed that the relationship is correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I checked Dgraph logic (outputnode.go - normalize() function)
The root level's uid is added as a scalar, and the merge function appends child values after parent values, the root uid will always be first in the flattened result, followed by nested uids in depth-first order.
That said we probably have a bug in Dgraph itself because the behavior is different if we query also a scalar predicate in the block having @normalize which is alphabetically before UID (like name !).

I suggest we merge this so Ratel handles the uid array case and investigate Dgraph logic using @normalize and debug.

@raphael-istari raphael-istari merged commit f804b6a into main Jan 21, 2026
6 checks passed
@raphael-istari raphael-istari deleted the 399-render-graph-view-with-normalized-nodes branch January 21, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Render Graph view with nested @normalize nodes

2 participants