The query below should look for participants for a given uid interaction and produce a list with only participants that also are users. So far so good, @cascade does the job eliminating whoever are not a user.
But, as a “bonus” I would like to receive the uid of a parent interaction in the case that the given uid is from a sub interaction. All goes well if we are indeed in a sub interaction, but if the uid is from a top interaction itself, and as so it does not have the “~interactions” edge the it triggers the all global @cascade and I end up with nothing.
So the only solution that left for me is doing things in several steps, or by code, or by taking overcomplicated results and parsing them just to have the best of the two worlds.
This is one case that you should be able to turn cascade ON or OFF per branch / query level.
{
q(func: uid(0x11a0)) @cascade @normalize{
interaction_uid: uid
~interactions {
top_uid: uid
}
participants {
dude_uid: uid
emails{
mail_uid: uid
users: ~emails {
user_uid: uid
user: user
}
}
}
}
}
Should be:
{
q(func: uid(0x11a0)) @normalize{
interaction_uid: uid
~interactions {
top_uid: uid
}
participants @cascade { # Cascade would be on for this branch
dude_uid: uid
emails{
mail_uid: uid
users: ~emails {
user_uid: uid
user: user
}
}
}
}
}
Or
{
q(func: uid(0x11a0)) @normalize @cascade{
interaction_uid: uid
~interactions @cascade_off { # with this aproach, a global cascade would be off for this branch
top_uid: uid
}
participants { # Cascade would be on for this branch
dude_uid: uid
emails{
mail_uid: uid
users: ~emails {
user_uid: uid
user: user
}
}
}
}
}
Of course, the same goes to @normalize that should behave the same.