Skip to Content

ProductGroupConnection

A connection type for paginating through a list of ProductGroup items using cursor-based pagination. This connection enables efficient navigation through large datasets by providing cursors to mark positions within the list.

Connection Structure

{ edges: [ProductGroupEdge!]! pageInfo: PageInfo! }

Pagination Arguments

  • first: Int
    Returns the first n elements from the list. Must be a positive integer.

  • last: Int
    Returns the last n elements from the list. Must be a positive integer.

  • before: String
    Returns elements before the specified cursor.

  • after: String
    Returns elements after the specified cursor.

These arguments allow flexible forward and backward navigation through the paginated list.

PageInfo Structure

{ hasNextPage: Boolean! hasPreviousPage: Boolean! startCursor: String endCursor: String }
  • hasNextPage: Indicates if there are more items after the current page.
  • hasPreviousPage: Indicates if there are more items before the current page.
  • startCursor: The cursor corresponding to the first item in the current page.
  • endCursor: The cursor corresponding to the last item in the current page.

Usage Examples

Basic Pagination

Fetch the first 5 product groups:

{ productGroups(first: 5) { edges { node { id name } cursor } pageInfo { hasNextPage endCursor } } }

Forward Pagination

Fetch the next 5 product groups after a given cursor:

{ productGroups(first: 5, after: "YXJyYXljb25uZWN0aW9uOjQ=") { edges { node { id name } cursor } pageInfo { hasNextPage endCursor } } }

Backward Pagination

Fetch the previous 5 product groups before a given cursor:

{ productGroups(last: 5, before: "YXJyYXljb25uZWN0aW9uOjEw") { edges { node { id name } cursor } pageInfo { hasPreviousPage startCursor } } }

Cursor-based Navigation

Navigate through pages using cursors:

{ productGroups(first: 3) { edges { node { id name } cursor } pageInfo { hasNextPage endCursor } } }

Use the endCursor from the response to fetch the next page:

{ productGroups(first: 3, after: "YXJyYXljb25uZWN0aW9uOjM=") { edges { node { id name } cursor } pageInfo { hasNextPage endCursor } } }

Combined with Filtering

Assuming the API supports filtering by category and sorting by createdAt (only if these arguments are defined in the schema), you can combine pagination with filtering and sorting as follows:

{ productGroups(first: 5, after: "YXJyYXljb25uZWN0aW9uOjU=", filter: { category: "electronics" }, sortBy: { field: CREATED_AT, direction: DESC }) { edges { node { id name category createdAt } cursor } pageInfo { hasNextPage endCursor } } }

Note: Replace filter and sortBy with actual arguments if available in the schema.

Edge Type

type ProductGroupEdge { node: ProductGroup cursor: String! }
  • node: The ProductGroup item at the end of this edge. This field is optional and may be null.
  • cursor: A non-null string used for pagination to mark the position of this edge in the connection.

Each edge represents a single ProductGroup and its associated cursor, enabling precise navigation.

Pagination Best Practices

  • Use first with after for forward pagination to efficiently load subsequent pages.
  • Use last with before for backward pagination to load previous pages.
  • Always check pageInfo.hasNextPage and pageInfo.hasPreviousPage before attempting to fetch more pages.
  • Avoid large page sizes to reduce response time and server load.
  • Handle empty results gracefully by checking if edges is empty.
  • Cache cursors if you need to allow users to jump back and forth between pages.

Performance Considerations

  • Cursor-based pagination is more performant and reliable than offset-based pagination for large datasets.
  • Avoid requesting excessively large page sizes to prevent timeouts and high memory usage.
  • Use filtering and sorting arguments to reduce the amount of data transferred and processed.
  • Monitor rate limits and optimize queries accordingly to avoid throttling.
  • ProductGroup — The node type contained in each edge.
  • PageInfo — Provides metadata about pagination state.
  • String — The scalar type used for cursors.

Notes

  • The API currently requires no authentication for accessing ProductGroupConnection queries; however, this may change in future versions.
  • Always handle errors returned by the API, such as invalid cursors or argument values.
  • When no results are returned, the edges array will be empty, and pageInfo fields will reflect the absence of further pages.
  • Rate limiting may apply to paginated queries; implement retry logic and backoff strategies as needed.
Last updated on