Paginate Response

In Zoho CRM GraphQL APIs, to paginate over the result set , offset and limit arguments are used. Refer here to learn more about arguments of Record field.

When you send a query, you can ask for details of _info object which contains:

  • next_offset consists of offset value of the next page.
  • previous_offsetconsists of offset value of the previous page.
  • more_recordsboolean value that indicates whether more records are present or not for the query.

The result set of each query contains cursorsknown as next_offset and previous_offset containing details of the previous and next page. You can use these offset values for querying the next or previous set of records. Also, you can use limit input field to define the maximum number of records to fetch as part of this query.

First query

Copiedquery {
  Records {
    Contacts(limit:100){
      _data {
        Email{value}
        Last_Name{value}
        id{value}
      }
  _info {
    previous_offset
    next_offset
    more_records
  }
    }
  }
}

Response

Copied{
  "data": {
    "Records": {
      "Contacts": {
        "__data": [
          {
            "Last_Name": {
              "value": "boyle"
            },
            "Email": {
              "value": "p.boyle@gmail.com"
            },
            "id": {
              "value": "29830000000007878"
            }
          },
          {
            "Last_Name": {
              "value": "smith"
            },
            "Email": {
              "value": "j.smith@gmail.com"
            },
            "id": {
              "value": "29830000000007878"
            }
          }
       .
       .
       .
       .
       .
        ],
        "__info": {
          "previous_offset": null,
          "next_offset": "88c0ce62b6f8e7703d8e7bd4bec897899cd471b67a448ca7f63e346d46d7ac2fdc1640ca92113de4e1b68d535a4293be7e3bf9fa7e981c2578c175ea0fe5e7a840331f4a318454b75e7070ffc34b0eef",
          "more_records": true
        }
      }
    }
  }
}

Second query : offset obtained from the response of the first query is used here to get the next set.

Copiedquery {
  Records {
    Contacts(limit:100,offset:"88c0ce62b6f8e7703d8e7bd4bec897899cd471b67a448ca7f63e346d46d7ac2fdc1640ca92113de4e1b68d535a4293be7e3bf9fa7e981c2578c175ea0fe5e7a840331f4a318454b75e7070ffc34b0eef"){//offset from previous query
      __data {
        Email{value}
        Last_Name{value}
        id{value}
      }
  __info {
    previous_offset
    next_offset
    more_records
  }
    }
  }
}