We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.

Every type with fields whose types can be ordered (Int, Float, String, DateTime) gets ordering built into the query and any list fields of that type. Every query and list field gets pagination with first and offset and ordering with order parameter.

The order parameter isn’t required for pagination.

For example, find the most recent 5 posts.

queryPost(order: { desc: datePublished }, first: 5) { ... }

Skip the first five recent posts and then get the next 10.

queryPost(order: { desc: datePublished }, offset: 5, first: 10) { ... }

It is also possible to give multiple orders. For example, sort by date and within each date order the posts by number of likes.

queryPost(order: { desc: datePublished, then: { desc: numLikes } }, first: 5) { ... }