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(director.film)) {
    director.film {
      stars as count(starring)
    }
    totalActors as sum(val(stars))
  }

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

    director.film {
      name@en
    }
  }
}

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 https://github.com/dgraph-io/dgraph/issues/2099. 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 https://github.com/dgraph-io/dgraph/commit/e05f0fd6ef685773bf2424dbcfed4d810accf0bf 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.