fix: render graph view correctly with nested @normalize nodes#402
Conversation
handle the case of uid is an array after normalized query (and debug mode adding uid at every level)
| // 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() |
There was a problem hiding this comment.
@raphael-istari By just taking the first uid, are we guaranteed that the relationship is correct?
There was a problem hiding this comment.
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.
Fixes #399
handle the case of uid is an array after normalized query (and debug mode adding uid at every level)
Checklist