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
  }
}

I thought about it, but I need a way to divide queries between each other. Because in this way I got a bunch of entities without any way to mark them with a correct alias in the result JSON.
I would like to do it as:

{
  group1: group1 {
    expand(_all_)
  }
  group2: group2 {
    expand(_all_)
  }
}

And then filter and paginate result of the query.
I tried to use query variables but idk why it doesn’t work.

variable as var(func: condition1)
data(func: uid(variable)) {
   uid(variable) {
      expand(_all_)
  }
}

It says, I can’t using uid with a variable, though documentation says it’s possible to use uid() with a variable :expressionless: