It’s not uncommon to have thousands of results for a query.
But you might want to paginate the results for display, or limit a large result set.
Dgraph generates first
and offset
arguments that can be used in combination
to achieve such limits and paginate results:
first: N
Return only the first N
resultsoffset: N
Skip the first N
resultsBy default, query answers are ordered by uid
. You can change this behavior by
explicitly specifying an order.
The first
and offset
arguments are available on query<Type>
queries and on
any edge to a list of nodes.
{
getPerson(xid: "alice") {
id
name
friends(order: { asc: name }, offset: 1, first: 2) {
id
name
}
}
}
2.8 Pagination (first and offset)