Skip to Content

PreviousPriceConnection

The PreviousPriceConnection type represents a paginated list of PreviousPrice items. It follows the cursor-based pagination model, allowing efficient navigation through large sets of historical pricing data. This connection provides edges containing individual PreviousPrice nodes and cursors to paginate forward or backward through the list.

Connection Structure

{ edges: [PreviousPriceEdge] pageInfo: PageInfo }

Pagination Arguments

The connection supports the following pagination arguments to control the slice of data returned:

ArgumentTypeDescription
firstIntReturns the first n elements from the list. Must be a positive integer.
lastIntReturns the last n elements from the list. Must be a positive integer.
beforeStringReturns elements preceding the specified cursor.
afterStringReturns elements following the specified cursor.

Constraints:

  • You cannot use first and last together in the same query.
  • When using before or after, the cursor must be a valid string returned from a previous query.
  • Pagination arguments must be used to limit the number of items returned for performance and rate limiting reasons.

PageInfo Structure

The pageInfo object provides metadata about the current page of results:

{ hasNextPage: Boolean hasPreviousPage: Boolean startCursor: String endCursor: String }
  • hasNextPage: Indicates if there are more items when paginating forward.
  • hasPreviousPage: Indicates if there are more items when paginating backward.
  • 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 previous prices:

{ previousPrices(first: 5) { edges { node { id amount currency effectiveDate } cursor } pageInfo { hasNextPage endCursor } } }

Forward Pagination

Fetch the next 5 previous prices after a given cursor:

{ previousPrices(first: 5, after: "YXJyYXljb25uZWN0aW9uOjQ=") { edges { node { id amount currency effectiveDate } cursor } pageInfo { hasNextPage endCursor } } }

Backward Pagination

Fetch the last 5 previous prices before a given cursor:

{ previousPrices(last: 5, before: "YXJyYXljb25uZWN0aW9uOjEw") { edges { node { id amount currency effectiveDate } cursor } pageInfo { hasPreviousPage startCursor } } }

Cursor-based Navigation

Navigate through pages using cursors:

  1. Fetch first 3 items:
{ previousPrices(first: 3) { edges { node { id amount } cursor } pageInfo { hasNextPage endCursor } } }
  1. Use endCursor from previous query to fetch next 3 items:
{ previousPrices(first: 3, after: "YXJyYXljb25uZWN0aW9uOjM=") { edges { node { id amount } cursor } pageInfo { hasNextPage endCursor } } }

Combined with Filtering

You can combine pagination with filtering arguments (if supported by the query) such as filtering by currency or date range. For example, fetching the first 5 previous prices in USD:

{ previousPrices(first: 5, currency: "USD") { edges { node { id amount currency effectiveDate } cursor } pageInfo { hasNextPage endCursor } } }

Note: Filtering arguments like currency must be supported by the previousPrices query.

Edge Type

The PreviousPriceEdge type represents a single edge in the connection:

{ node: PreviousPrice cursor: String }
  • node: The PreviousPrice item at the end of the edge. This field may be null if the item is unavailable.
  • cursor: An opaque string used to paginate to this edge.

Pagination Best Practices

  • Always specify a first or last argument to limit the number of items returned.
  • Use cursors (after or before) to paginate efficiently rather than relying on offset-based pagination.
  • Avoid large page sizes to reduce response time and resource consumption.
  • Combine pagination with filtering and sorting to retrieve relevant data subsets.
  • Handle empty results gracefully by checking if edges is an empty array.
  • Use pageInfo fields to determine if further pagination is possible.

Performance Considerations

  • Cursor-based pagination is optimized for performance and consistency, especially with frequently changing data.
  • Large page sizes can impact server response time and increase rate limiting risk.
  • Use selective field queries to minimize payload size.
  • Cache cursors and results on the client side where appropriate to reduce repeated requests.
  • PreviousPrice — Represents the historical price data item contained in each edge.

Notes

  • The API currently requires no authentication for querying PreviousPriceConnection, but this may change in future versions.
  • Always validate cursors before using them in queries to avoid errors.
  • Handle errors gracefully, such as invalid cursor or exceeding rate limits.
  • Rate limiting applies to paginated queries; paginate responsibly to avoid throttling.
Last updated on