Dgraph DQL Tour

Basic

Pagination (first, offset and after)

It’s not uncommon to have thousands of results for a query.

But you might want to select only the top-k answers, paginate the results for display, or limit a large result.

In DQL this is done with first, offset and after in combination with ordering.

  • first: N Return only the first N results
  • offset: N Skip the first N results
  • after: uid Return the results after uid

By default, query answers are ordered by uid. You can change this behavior by explicitly specifying an order.

after makes sense in pagination when we only know the last uid returned and don’t record how many results have previously been retrieved.

2.9 Pagination (first, offset and after)