How to paginate using queries (for reference: https://facebook.github.io/relay/graphql/connections.htm)

This is just an example and is applicable to other queries.

Let's dive into pageInfo hash, what it is and how it can be used.

Name

Type

Description

Query Head Example

first

Integer

How many items will be returned from the beginning of the list.

leads(usingToolSlugs: ["gmail"], toolMatch: "any",
first: 3)

after

String

The client will show the results after $endCursor.

usingToolSlugs: ["gmail"], toolMatch: "any",
after: "MjU")

before

String

The client will show the results before $beforeCursor.

leads(usingToolSlugs: ["gmail"], toolMatch: "any",
before: "MjY")

last

Int

How many items will be returned from end of the list.

leads(usingToolSlugs: ["gmail"], toolMatch: "any",
last: 3)

Edge at PageInfo

The information about the cursors can be found using this edge. The sample query of pageInfo is below:

pageInfo {
  startCursor
  hasNextPage
  endCursor
  hasPreviousPage
}

The response is as follows:

"pageInfo": {
  "startCursor": "MzA3NDQx",
  "hasNextPage": false,
  "endCursor": "MzA3NDQz",
  "hasPreviousPage": true
}

Name

Type

Description

startCursor

String

The ID of the page before. In other words, this is the cursor to the pervious page.

hasNextPage

Boolean

After the result, mean if is there any result that hasn't shown after the page in the response.

endCursor

String

The ID of the page after. In other words, this is the cursor to the next page.

hasPreviousPage

Boolean

After the result, mean if is there any result that hasn't shown after the page in the response.

Language
Authentication
Query