Pagination

Queries return up to 30 results unless you specify a different limit (page size) with the first parameter.

When there are many records in the results, applications should retrieve "pages" of results instead of all results. For example, retrieve the first 200 results, then retrieve the next 200 results, until done. Such pagination improves performance and makes the results manageable.

Note: The totalCount value is always the count of all records that matched the filter, regardless of page size.

Queries that perform pagination have this basic structure:

feedback(
  filter:{},    # Filter object.
  after: null,  # Cursor starting point for the current page
  first: 200    # Page size
){
  pageInfo{
    endCursor   # Use this as the 'after' parameter in the next query
    hasNextPage # True when there are more records available past the current page
  }
  totalCount    # Number of records that matched the filter
  …

Where:

  • filter identifies the records to retrieve.

  • after is a cursor that identifies where to start the page. For the initial query, the value is null, but for subsequent queries, it is an encoded string representing the "last result" at the end of the previous page, as identified by the endCursor value.

  • first is the page size: return up to this many results.

  • endCursor is an encoded string representing the last result in the page, and is the value to use as the after in the next page.

  • hasNextPage is true when there are more records after the current page.

  • totalCount is the number of records that match the filter criteria.

To perform pagination,

  1. Perform a query with a limited page size (first).

  2. If hasNextPage is true, repeat the query but change to be the value returned by endCursor in the previous query.

  3. Repeat step 2 until hasNextPage is false.

This illustration shows pagination over a set of 246 results, where the page size is 100:

246 results divided into three pages, where 'endCursor' from the previous page is 'after' in the next page

Note: Pagination must be performed sequentially from first to last. It is not possible in code to pre-calculate the endCursor string.

Example: Pagination

To request paginated results and navigate the pages, request the pageInfo node, and use the endCursor and hasNextPage values as parameters for the next call.

Example: use pagination

query getFeedback($pagesize: Int!, $cursor: ID, $filter: Filter){
        feedback(first: $pagesize, after: $cursor, filter:$filter){
            totalCount 
	    pageInfo{
                hasNextPage
                endCursor
            }
            nodes{
                e_responsedate:fieldData(fieldId:"e_responsedate"){... fieldData}
                a_fullname:fieldData(fieldId:"a_fullname"){... fieldData}
                e_email:fieldData(fieldId:"e_email"){... fieldData}
                q_bp_wm_client_ltr_scale:fieldData(fieldId:"q_bp_wm_client_ltr_scale"){... fieldData}
            }
        }
    }
    fragment fieldData on FieldData{
        ... on EnumFieldData{options{name}}
        ... on StringFieldData{values}
        ... on IntFieldData{values}
        ... on DateFieldData{values}
        ... on UnitFieldData{units{name}}
    }

Example: Variables

{
   "cursor":null,
   "filter":{
      "and":[
         {
            "fieldIds":["e_responsedate"],
            "gt":"2016-02-01"
         },
         {
            "fieldIds":["q_bp_wm_client_ltr_scale"],
            "gte":"1"
         },
         {
            "fieldIds":["q_bp_wm_client_ltr_scale"],
            "lte":"8"
         }
      ]
   },
   "pagesize":5
}

Sample response

{
  "data": {
    "feedback": {
      "totalCount": 1041,
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "xcCgiIuHBlOoSB04bhaYC"
      },
      "nodes": [
        {
          "e_responsedate": {},
          "a_fullname": {
            "values": [
              "Ramos, Katherine"
            ]
          },
          "e_email": {
            "values": [
              "medalliademo_159957@example.com"
            ]
          },
          "q_bp_wm_client_ltr_scale": {
            "options": [
              {
                "name": "5"
              }
            ]
          }
        },
        {
          "e_responsedate": {},
          "a_fullname": {
            "values": [
              "Evans, Willie"
            ]
          },
          "e_email": {
            "values": [
              "medalliademo_159901@example.com"
            ]
          },
          "q_bp_wm_client_ltr_scale": {
            "options": [
              {
                "name": "1"
              }
            ]
          }
        },
        {
          "e_responsedate": {},
          "a_fullname": {
            "values": [
              "Perez, Heather"
            ]
          },
          "e_email": {
            "values": [
              "medalliademo_159837@example.com"
            ]
          },
          "q_bp_wm_client_ltr_scale": {
            "options": [
              {
                "name": "3"
              }
            ]
          }
        },
        {
          "e_responsedate": {},
          "a_fullname": {
            "values": [
              "Mcdonald, Wanda"
            ]
          },
          "e_email": {
            "values": [
              "medalliademo_159802@example.com"
            ]
          },
          "q_bp_wm_client_ltr_scale": {
            "options": [
              {
                "name": "6"
              }
            ]
          }
        },
        {
          "e_responsedate": {},
          "a_fullname": {
            "values": [
              "Richardson, Julia"
            ]
          },
          "e_email": {
            "values": [
              "medalliademo_159702@example.com"
            ]
          },
          "q_bp_wm_client_ltr_scale": {
            "options": [
              {
                "name": "6"
              }
            ]
          }
        }
      ]
    }
  },
  "errors": null,
  "_links": null,
  "_allowed": [
    "POST",
    "GET"
  ]
}