refactor(base-data-service)!: require getNextPageParam and initialPageParam (align with TanStack) - #9872
Closed
cryptodev-2s wants to merge 3 commits into
Conversation
…eParam Align `fetchInfiniteQuery` with `@tanstack/query-core`'s own contract: make `getNextPageParam` and `initialPageParam` required (`getPreviousPageParam` stays optional). This drops the no-op `getNextPageParam` fallback and the `initialPageParam` cast from the base method, and removes the callback-free usage entirely. * Collapse `ExampleDataService.getActivity` and `getActivityByCursor` into a single `getActivity` (with callbacks, a `null` first-page param, a configurable `staleTime`). * Update `MoneyAccountApiDataService.fetchHistory` to provide `getNextPageParam` (from `next_cursor`) and `initialPageParam: null`, with a test that refetches a stale multi-page query so the resolver is exercised.
cryptodev-2s
force-pushed
the
refactor/base-data-service-strict-infinite-query
branch
from
August 14, 2026 00:02
b5aa462 to
bc5dd11
Compare
cryptodev-2s
deleted the
refactor/base-data-service-strict-infinite-query
branch
August 14, 2026 18:24
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.
Proposal (stacked on #9712)
Opening this for the team to decide. It makes
BaseDataService.fetchInfiniteQueryalign with@tanstack/query-core's ownfetchInfiniteQueryby requiringgetNextPageParamandinitialPageParam(leavinggetPreviousPageParamoptional, for backward pagination).Why
On #9712 we ended up with two example methods (
getActivitywith page-param callbacks,getActivityByCursorwithout) because the base method allows omitting the callbacks. That optionality is also what forced a no-opgetNextPageParamfallback and some extra handling. Requiring the callbacks removes the callback-free path, so:getActivityexample instead of twogetNextPageParamfallback and theinitialPageParamcastWhat changes
BaseDataService.fetchInfiniteQueryoptions:getNextPageParamandinitialPageParamare now required.ExampleDataService: collapsed to a singlegetActivity(callbacks,nullfirst-page param, configurablestaleTime).MoneyAccountApiDataService.fetchHistory: now providesgetNextPageParam(fromnext_cursor) andinitialPageParam: null.Cost to surface for the discussion
This is a breaking change to the base contract, and it pushes work onto consumers:
getNextPageParam+initialPageParam.getNextPageParamis only exercised on a multi-page stale refetch, so consumers also need a refetch test to keep 100% coverage.MoneyAccountneeded a new "refetches all cached pages when stale" test here for exactly that reason.If we're fine with that trade, this is the cleaner end state. If not, #9712 stands on its own with the two-method approach.
Verification
Changelog to follow once we agree on direction.