Skip to content

fix(base-data-service): adapt to @tanstack/query-core v5 API - #9712

Draft
cryptodev-2s wants to merge 1 commit into
update-tanstack-query-core-v5from
fix/query-core-v5-base-data-service
Draft

fix(base-data-service): adapt to @tanstack/query-core v5 API#9712
cryptodev-2s wants to merge 1 commit into
update-tanstack-query-core-v5from
fix/query-core-v5-base-data-service

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What

Stacked on top of #9686. That PR bumps @tanstack/query-core this adapts the code to v5.

Changes

packages/base-data-service/src/BaseDataService.ts

  • invalidateQueries filter type: in v5 the generic is the query key (constrained to readonly unknown[]), not page data, so InvalidateQueryFilters<Json> no longer type checks. Dropped the argument to keep the loose v4 ergonomics.
  • queryFn can now be the skipToken sentinel (a unique symbol, not callable). Typed the options so queryFn is always a concrete function, since data services never use skipToken.
  • fetchInfiniteQuery: v5 requires initialPageParam, and fetchMore meta no longer carries an explicit pageParam (v5 derives it from getNextPageParam / getPreviousPageParam). Now passes initialPageParam and injects page param resolvers at query.fetch time so pagination still fetches the exact requested page. This keeps cursor pagination working even for consumers that do not define page param callbacks.

packages/chomp-api-service/src/chomp-api-service.ts

  • cacheTime was renamed to gcTime in v5. Without this, the "evict on settle" behavior stopped working.

Tests / helpers

  • hashQueryKey was renamed to hashKey.
  • dehydrate now writes a dehydratedAt field into query state.
  • Renamed cacheTime to gcTime and typed the page param in the example service.

Why the injection matters

MoneyAccountApiDataService paginates via an explicit cursor without defining getNextPageParam. Under the raw v5 bump its pagination test crashed with options.getNextPageParam is not a function. The resolver injection restores that behavior.

The v5 bump updated the package.json versions but left the v4 API usage
in place, so the build fails. This adapts the code to v5.

* `invalidateQueries` filter: the generic is now the query key (not page
  data), so drop the `Json` argument
* handle the new `skipToken` sentinel by typing `queryFn` as a concrete
  function (data services never use it)
* `fetchInfiniteQuery`: pass `initialPageParam` and inject page param
  resolvers at fetch time, since v5 no longer accepts an explicit
  `pageParam` via `fetchMore` meta. This keeps cursor pagination working
  for consumers that do not define page param callbacks
* chomp: `cacheTime` is now `gcTime`
* tests: `hashQueryKey` is now `hashKey`, and `dehydrate` adds a
  `dehydratedAt` field
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant