How to use variables for pagination?

Hi All,

I am trying to page query results, following the documentation example I have come up with the following query.

query test($a: int = 2, $name: string = "Steven") {
  ID as var(func: allofterms(name@en, $name)) @filter(has( { {
      stars as count(starring)
    totalActors as sum(val(stars))

  mostStars(func: uid(ID), orderdesc: val(totalActors), first: $a) {
    stars : val(totalActors) {

Running this query gives me:

Expecting a comma. Got: lex.Item [9] "a"

However, replacing first: $a, with first: 2 works as expected. Am missing something here?

Hey @monish

I think this is a bug related to It should be easy to fix though. I am going to work on a fix now and should have something for you soon.

I have merged a fix to master with and it would be part of the nightly release.

Thanks for the quick fix!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.