fix(base-data-service): adapt to @tanstack/query-core v5 API - #9712
Draft
cryptodev-2s wants to merge 1 commit into
Draft
fix(base-data-service): adapt to @tanstack/query-core v5 API#9712cryptodev-2s wants to merge 1 commit into
@tanstack/query-core v5 API#9712cryptodev-2s wants to merge 1 commit into
Conversation
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
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.