Hello,
I have a linked list structure that I want to traverse. I was able to use recurse to go through the entire list which worked like a charm, but I want to see if it’s possible to normalize the data so that it isn’t so deeply nested.
Here is the basic schema for the structure. The Event type has a nextEvent predicate on it that points to another node of type Event.
<Event.nextEvent>: uid .
<Event.type>: string .
type <Event> {
Event.type
Event.nextEvent
}
I was able to use recurse to query the list like so
{
test(func: uid(0x274b)) @recurse {
uid
Event.type
Event.nextEvent
}
}
And the response
"data": {
"test": [
{
"uid": "0x274b",
"Event.type": "Test Event",
"Event.nextEvent": {
"uid": "0x274d",
"Event.type": "Test Event",
"Event.nextEvent": {
"uid": "0x274e",
"Event.type": "Test Event",
"Event.nextEvent": {
"uid": "0x274f",
"Event.type": "Hello Event"
}
}
}
}
]
}
Is there anyway to flatten this data so that it isn’t so deeply nested? I tried using @normalize but I’m struggling to get the results I want which would look something like an array with the nodes.
Thanks in advance!