fix(base-data-service): adapt to @tanstack/query-core v5 API - #9712
Open
cryptodev-2s wants to merge 10 commits into
Open
fix(base-data-service): adapt to @tanstack/query-core v5 API#9712cryptodev-2s wants to merge 10 commits into
@tanstack/query-core v5 API#9712cryptodev-2s wants to merge 10 commits into
Conversation
cryptodev-2s
changed the base branch from
update-tanstack-query-core-v5
to
main
August 3, 2026 21:46
cryptodev-2s
force-pushed
the
fix/query-core-v5-base-data-service
branch
from
August 3, 2026 21:46
def5a29 to
88ec84f
Compare
cryptodev-2s
marked this pull request as ready for review
August 4, 2026 10:09
cryptodev-2s
force-pushed
the
fix/query-core-v5-base-data-service
branch
from
August 4, 2026 10:09
637de58 to
6dbe63d
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
cryptodev-2s
added a commit
that referenced
this pull request
Aug 4, 2026
… param callbacks query-core v5 walks `getNextPageParam` when it refetches an infinite query that has more than one page cached. Consumers that paginate by explicit cursor without defining `getNextPageParam` (like `MoneyAccountApiDataService`) would throw once a second page was cached and a stale refetch with no page param ran. Default `getNextPageParam` to a resolver that returns `null` so the refetch rebuilds just the first page instead of throwing. The consumer repopulates the cache by navigating again with explicit page params. Also adds a `fetchInfiniteQuery` test suite covering forward and backward navigation with and without page param callbacks, single page returns, `staleTime` deduplication, and this refetch regression. Flagged by Cursor Bugbot on #9712.
A recent PR updated this package to v5 in one package (#9563). This PR updates to v5 in all remaining packages.
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
… param callbacks query-core v5 walks `getNextPageParam` when it refetches an infinite query that has more than one page cached. Consumers that paginate by explicit cursor without defining `getNextPageParam` (like `MoneyAccountApiDataService`) would throw once a second page was cached and a stale refetch with no page param ran. Default `getNextPageParam` to a resolver that returns `null` so the refetch rebuilds just the first page instead of throwing. The consumer repopulates the cache by navigating again with explicit page params. Also adds a `fetchInfiniteQuery` test suite covering forward and backward navigation with and without page param callbacks, single page returns, `staleTime` deduplication, and this refetch regression. Flagged by Cursor Bugbot on #9712.
cryptodev-2s
force-pushed
the
fix/query-core-v5-base-data-service
branch
from
August 4, 2026 13:13
4561b46 to
5a1dcce
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5a1dcce. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Stacked on top of #9686. That PR bumps
@tanstack/query-corethis adapts the code to v5.Changes
packages/base-data-service/src/BaseDataService.tsinvalidateQueriesfilter type: in v5 the generic is the query key (constrained toreadonly unknown[]), not page data, soInvalidateQueryFilters<Json>no longer type checks. Dropped the argument to keep the loose v4 ergonomics.queryFncan now be theskipTokensentinel (aunique symbol, not callable). Typed the options soqueryFnis always a concrete function, since data services never useskipToken.fetchInfiniteQuery: v5 requiresinitialPageParam, andfetchMoremeta no longer carries an explicitpageParam(v5 derives it fromgetNextPageParam/getPreviousPageParam). Now passesinitialPageParamand injects page param resolvers atquery.fetchtime 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.tscacheTimewas renamed togcTimein v5. Without this, the "evict on settle" behavior stopped working.Tests / helpers
hashQueryKeywas renamed tohashKey.dehydratenow writes adehydratedAtfield into query state.cacheTimetogcTimeand typed the page param in the example service.Why the injection matters
MoneyAccountApiDataServicepaginates via an explicit cursor without defininggetNextPageParam. Under the raw v5 bump its pagination test crashed withoptions.getNextPageParam is not a function. The resolver injection restores that behavior.Note
Medium Risk
Touches shared query caching and infinite pagination used by multiple API data services; behavior is heavily tested but a major dependency bump with documented breaking changes.
Overview
Bumps
@tanstack/query-corefrom v4 to v5 acrossbase-data-serviceand dependent packages, with breaking API surface called out in the changelog (cacheTime→gcTime, stricter option types, infinite-query behavior).BaseDataServiceis updated for v5:invalidateQueriesdrops the invalidInvalidateQueryFilters<Json>generic;fetchQuery/fetchInfiniteQueryrequire a realqueryFn(notskipToken).fetchInfiniteQuerynow suppliesinitialPageParam, defaults a no-opgetNextPageParamwhen consumers omit callbacks, and on cached multi-page fetches overrides next/previous resolvers atquery.fetchtime because v5 no longer passes an explicit page viafetchMoremeta—preserving cursor jumps for services like Money Account that only pass an explicitpageParam.Downstream fixes rename
cacheTimetogcTime(e.g. Chomp associated-addresses eviction). Tests switchhashQueryKey→hashKey, expectdehydratedAton persisted queries, and add broadfetchInfiniteQuerycoverage for callback vs callback-free pagination and stale rebuilds.Reviewed by Cursor Bugbot for commit ed03d25. Bugbot is set up for automated code reviews on this repo. Configure here.