Skip to content

Pagenated Queries

In the following examples, we have a table called students, which contains fields and relations like firstName, email, age.

The arguments skip and first get used for pagination.

first specifies the number of rows to pass from the result set and skip determines which slice to retain from the results.

Request

query MyQuery1 {
/**
* First consider 0 as the starting slice of paginated records. As this
* number is increased, the prior results leave out previously fetched
* records. (i.e., skip 0 -> skip 3 -> skip 6 -> skip 9...)
*/
students(skip: 0, first: 3,) {
items {
id
firstName
email
age
}
}
}

Response

{
"data": {
"students": {
"items": [
{
"id": "287cff0a-345b-4cca-9e9a-75a2161238fd",
"firstName": "James",
"email": "james.smith@example.com",
"age": 22
},
{
"id": "97fb89ac-e0ad-44f5-b671-24a1b751287c",
"firstName": "John",
"email": "john.williams@example.com",
"age": 23
},
{
"id": "429cf99f-4481-49c4-adb4-605731b20eb2",
"firstName": "Mary",
"email": "mary.brown@example.com",
"age": 24
}
]
}
}
}