I have this discussion Promise a nested block (under construction - I'm still working in the use case) which I have noted some use cases related to Variables in the same block. Dgraph won’t work well with variables in the same block and in different levels of the block if not an aggregation.
I think that is a huge work to analyze and make a decision on the design of the Query System. For now multiple blocks are the only way and can be tricky for some use cases. But I think two blocks for this case (of the topic itself) are acceptable. Something like:
{
I as var(func: type(invoice), first: 5000) @cascade {
purchase_orders {
workflows: ~purchase_orders @filter(type(workflow)) {
reg as regions { uid }
}
}
}
invoices(func: uid(I)) @cascade {
purchase_orders {
workflows: ~purchase_orders @filter(type(workflow)) {
locations {
regions @filter(uid(reg))
location_uid: uid
location: location.name
}
}
}
}
}
Also, internally I have this http://discuss.hypermode.com/t/improvement-on-the-query-system/8365