Pagination

1. Page-based pagination

Page-based pagination can be achieved through the use of the skip and limit options available whilst querying for data.

Using the following type definition:

type User {
    name: String!
}

You would fetch the first "page" of 10 by executing:

query {
    users(options: {
        limit: 10
    }) {
        name
    }
}

And then on subsequent calls, introduce the skip argument and increment it by 10 on each call.

Page 2:

query {
    users(options: {
        skip: 10
        limit: 10
    }) {
        name
    }
}

Page 3:

query {
    users(options: {
        skip: 20
        limit: 10
    }) {
        name
    }
}

1.1. Paginating relationship fields

Say that in addition to the User type above, there is also a Post type which a User has many of. You can also fetch a User and then paginate through their posts:

query {
    users(where: {
        name: "Billy"
    }) {
        name
        posts(options: {
            skip: 20
            limit: 10
        }) {
            content
        }
    }
}