📚
Slickgrid-Universal
Live DemoGitHubOther Frameworks
  • Introduction
  • Getting Started
    • Quick start
    • Salesforce (LWC)
    • Vanilla Installation
  • Styling
    • Dark Mode
    • Styling CSS/SASS/Themes
  • Column Functionalities
    • Cell Menu (Action Menu)
    • Editors
      • Autocomplete
      • old Date Picker (flatpickr)
      • new Date Picker (vanilla-calendar)
      • LongText (textarea)
      • Select Dropdown Editor (single/multiple)
    • Filters
      • Input Filter (default)
      • Select Filter (dropdown)
      • Compound Filters
      • Range Filters
      • Styling Filled Filters
      • Single Search Filter
    • Formatters
    • Sorting
  • Events
    • Available events
    • On Events
  • Grid Functionalities
    • Auto-Resize / Resizer Service
    • Resize by Cell Content
    • Column Picker
    • Composite Editor Modal
    • Custom Tooltip
    • Column & Row Spanning
    • Context Menu
    • Custom Footer
    • Excel Copy Buffer Plugin
    • Export to Excel
    • Export to File (csv/txt)
    • Grid Menu
    • Grid State & Presets
    • Grouping & Aggregators
    • Header Menu & Header Buttons
    • Pagination
    • Infinite Scroll
    • Pinning (frozen) of Columns/Rows
    • Row Detail
    • Row Selection
    • Tree Data Grid
    • Row Based Editing Plugin
  • Developer Guides
    • CSP Compliance
  • Localization
    • with I18N
    • with Custom Translate Service
    • with Single Locale
  • Backend Services
    • Custom Backend Service
    • OData
    • GraphQL
      • JSON Result Structure
      • Filtering Schema
      • Pagination Schema
      • Sorting Schema
  • Migrations
    • Migration Guide to 1.x (2021-12-11)
    • Migration Guide to 2.x (2022-10-17)
    • Migration Guide to 3.x (2023-05-29)
    • Migration Guide to 4.x (2023-12-15)
    • Migration Guide to 5.x (2024-05-10)
    • Versions 6 to 8 are skipped...
    • Migration Guide to 9.x (2025-05-10)
Powered by GitBook
On this page
  1. Backend Services
  2. GraphQL

Pagination Schema

PreviousFiltering SchemaNextSorting Schema

Last updated 1 year ago

The implementation of a GraphQL Service requires a certain structure to follow for Slickgrid-Universal to work correctly (it will fail if your GraphQL Schema is any different than what is shown below).

Implementation

For the implementation in your code, refer to the section.

Without Cursor (recommended)

Pagination without cursor, this is the simplest implementation and is what we use on our side. The query can have any of the 3 arguments:

  • first: integer representing how many rows of data to get from the start of dataset

  • last: integer representing how many rows of data to get from the end of dataset

  • offset: integer representing how many to skip

For example

users (first:20, offset: 10) {
  totalCount
  nodes {
    name
    gender
  }
}

With Cursor useCursor

Cursor Pagination is more generally used for real-time data scenarios. It usually reads sequentially from the head or tail of a list. It cannot navigate directly to the middle of a list. It conceptually treats the data similarly to a LinkedList as opposed to a Vector.

Pagination with cursor, the query can have any of the 4 arguments:

  • first: integer representing how many rows of data to get from the start of dataset

  • after: pull data starting at cursor "x", where "x" is the last item cursor

  • last: integer representing how many rows of data to get from the end of dataset

  • before: pull data before a cursor "x", where "x" is the last item cursor

For example

users (first:20, after:"YXJyYXljb25uZWN0aW9uOjM=") {
  totalCount
  pageInfo {
    hasPreviousPage
    hasNextPage
    startCursor
    endCursor
  }
  edges {
    cursor
    node {
      name
      gender
    }
  }
}

To retrieve subsequent data, the pageInfo.endCursor property should be used as part of the next query. eg:

users (first:20, after:"${pageInfo.endCursor}")

or when navigating backwards

users (last:20, before:"${pageInfo.startCursor}")

When using the paginationService, this is handled by calling setCursorPageInfo(pageInfo).

Also note the difference in behaviour between relay style pagination as it affects the returned pageInfo object. eg

relay pagination - Infinte scrolling appending data
  page1: {startCursor: A, endCursor: B }
  page2: {startCursor: A, endCursor: C }
  page3: {startCursor: A, endCursor: D }

non-relay pagination - Getting page chunks
  page1: {startCursor: A, endCursor: B }
  page2: {startCursor: B, endCursor: C }
  page3: {startCursor: C, endCursor: D }
GraphQL Service