Cascade Directive with Pagination produces unexpected results

Moved from GitHub dgraph/5930

Posted by amaster507:

What version of Dgraph are you using?

docker image dgraph :master v2.0.0-rc1-448-gd5892dc0c

Have you tried reproducing the issue with the latest release?

N/A as @cascade is only available for graphql in 20.07+

What is the hardware spec (RAM, OS)?

AWS ec2.large (8gb RAM, Ubuntu)

Steps to reproduce the issue (command/config used to run Dgraph).

I have a query that returns around 15K nodes and want to get the first 5 that match the @cascade directive as well. The result is 0. However if I remove the pagination limit then I get all the ones that match cascade.

I believe the problem is that pagination happens before the cascade directive on the rood of the query. Is there a way to reverse this order? I don’t see any need why someone would want to paginate and then apply a cascade directive :thinking:

This will return all of the completed Tasks:

query {
  queryTask @cascade {
    name
    completed
  }
}

This should return the first 5 completed Tasks, but it instead returns an empty set:

query {
  queryTask(first: 5) @cascade {
    name
    completed
  }
}

Expected behaviour and actual result.

I expect pagination to work in conjunction with cascade but that does not seem to be true. I understand for performance that pagination reduces the load much faster then cascade does, but I do not believe that is the understood effect.

I did test on Dgraph in Ratel and got similar results. So this issue is not specific to the graphql endpoint.

1 Like

josh-mercarto commented :

Also having this issue

quotationmarks-jzj commented :

Also having this issue

@amaster507 I think this is GraphQL, right? It should be moved to GraphQL issues.

1 Like

I believe it applies to both, I discovered it with GraphQL but also compared with DQL. I moved it now. It really applies to both.