Skip to content

Pagination options and metadata for item queries; adapters return AllOperationResult

Choose a tag to compare

released this 04 Dec 09:17
· 18 commits to working since this release

This release adds first-class pagination to item queries and aligns adapter contracts to return AllOperationResult. It also adjusts providers accordingly and updates tests to cover the new behavior.

New Features

  • Pagination options on queries (commit 78d9320):
    • CItemsQuery and PItemsQuery now accept an optional allOptions argument (e.g., limit, offset) and pass it to adapter.all as the third parameter: all(query, locations, allOptions).
    • Pagination metadata (PaginationMetadata) is tracked by the query components and exposed to consumers via their contexts.

Improvements

  • Consistent AllOperationResult handling (commit 78d9320):
    • Query components call adapter.all(query, locations, allOptions) and consume result.items and result.metadata.
    • Providers now handle results from adapter.all by reading result.items.
  • Refetch behavior and cache handling (commit 78d9320):
    • Queries refetch when allOptions changes.
    • Cache invalidation handlers refetch using the current query and pass the current allOptions through to adapter.all.
    • CItemsQuery tracks the current query in a ref to ensure refetches use up-to-date criteria (marked as “CRITICAL FIX: Track current query” in the changes).

Breaking Changes

  • Adapter contract change to AllOperationResult (commit 78d9320):
    • adapter.all is now expected to return an AllOperationResult object: { items, metadata }.
    • Code that previously expected adapter.all to return an array must be updated to read result.items.
    • Queries may pass a third parameter (allOptions) to adapter.all; adapters should accept this optional argument.
  • Provider metadata removal (commit 78d9320):
    • CItemsProvider and PItemsProvider no longer accept a metadata prop and no longer include metadata in their context values.
  • Base context type cleanup (commit 78d9320):
    • AItems.ContextType no longer includes metadata?: PaginationMetadata.

Testing Improvements

  • Updated tests to the AllOperationResult return shape (commit 78d9320):
    • Mocks for adapter.all now return { items, metadata }.
    • Expectations updated to include the third allOptions argument (void 0 when not provided).
    • Added pagination-focused tests: allOptions passthrough, metadata exposure via query context, refetch on allOptions change, and correct propagation during cache invalidation.

Dependency Updates

  • Bumped Fjell packages in package.json (commit 4de6061):
    • @fjell/cache: ^4.7.52 → ^4.7.53
    • @fjell/client-api: ^4.4.61 → ^4.4.62
    • @fjell/core: ^4.4.67 → ^4.4.68

Version

  • Set package version to 4.5.81 (commit fcaf323).