How to union query blocks

What I want to do

I want to union several query blocks and only then use pagination.

For example:

result(func: eq(param,value) {
     expand(Data)
     someVar as somePredicate 

   uid(resurseResVar)???
   val(resurseResVar)???
}
var(func:uid(someVar)) @recurse {
   resurseResVar as uid
}

And then I want to expand data from resurseResVar. But uid(resurseResVar) returns error. The same with the query variables if I set something like this:

resurseData as d(func:uid(someVar)) @recurse {
   uid
   somePredicate
}

I struggled with this with this lines from here:

  • varName as q(func: ...) { ... }
  • varName as var(func: ...) { ... }
    I don’t understand how to use query variables correctly in another query blocks.

Dgraph metadata

Dgraph version : v23.1.1 Dgraph codename : dgraph Dgraph SHA-256 : 75dea8f2b7c3cd6496d75a0a638eb8149195692df45f79fc84b2f270b7faf218 Commit SHA-1 : 724e4db Commit timestamp : 2024-04-13 00:27:02 +0530 Branch : HEAD Go version : go1.19.13 jemalloc enabled : true

@nikita

Try this

{
  var(func: ...) {
    uids_group1 as uid
  }

  var(func: ...) {
    uids_group2 as uid
  }

  var(func: ...) {
    uids_group3 as uid
  }

  Node(func: uid(uids_group3, uids_group2, uids_group1) , orderdesc: ... , first: ...) {
    uid
    dgraph.type
  }
}