init query rename and delegation
🎯 Changes
Implements #9135
- renames
fetchQueryandfetchInfiniteQuerytoqueryandinfiniteQuery - make new
fetch*aliases for the renamed methods - delegates the
prefetch*methods withqueryinstead offetchQuery - delegates
ensureQueryDatamethods toquerywithstaletime: 'static' - updates tests for QueryClient (straight copy of the fetch tests)
- added new methods to vue-query QueryClient subclass.
TODO when this is merged (I have stacked branchs for these)
- add new docs
- refactor all the other tests to use the new methods (can be split up by package)
- add deprecation tags to old methods
✅ Checklist
- [x] I have followed the steps in the Contributing guide.
- [x] I have tested this code locally with
pnpm run test:pr.
🚀 Release Impact
- [x] This change affects published code, and I have generated a changeset.
- [ ] This change is docs/CI/dev-only (no release).
Summary by CodeRabbit
-
New Features
- Added new imperative query methods (including infinite queries), exported InfiniteQueryExecuteOptions, and a public noop helper.
- select is supported on the new imperative query paths; fetchQuery/fetchInfiniteQuery continue to ignore select.
-
Chores
- Package bumps and renamed imperative surface with compatibility wrappers preserved.
-
Tests
- Expanded coverage for staleTime, infinite paging, prefetching, select interactions, edge cases and typings.
✏️ Tip: You can customize this high-level summary in your review settings.
🦋 Changeset detected
Latest commit: bf15113b2ec503d67a659909187148a16afd5af9
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 19 packages
| Name | Type |
|---|---|
| @tanstack/react-query | Minor |
| @tanstack/query-core | Minor |
| @tanstack/vue-query | Minor |
| @tanstack/react-query-devtools | Major |
| @tanstack/react-query-next-experimental | Major |
| @tanstack/react-query-persist-client | Major |
| @tanstack/angular-query-experimental | Patch |
| @tanstack/query-async-storage-persister | Patch |
| @tanstack/query-broadcast-client-experimental | Patch |
| @tanstack/query-persist-client-core | Patch |
| @tanstack/query-sync-storage-persister | Patch |
| @tanstack/solid-query | Patch |
| @tanstack/svelte-query | Patch |
| @tanstack/vue-query-devtools | Major |
| @tanstack/angular-query-persist-client | Patch |
| @tanstack/solid-query-persist-client | Patch |
| @tanstack/svelte-query-persist-client | Patch |
| @tanstack/solid-query-devtools | Patch |
| @tanstack/svelte-query-devtools | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Walkthrough
Adds new imperative execute methods query and infiniteQuery, exports QueryExecuteOptions / InfiniteQueryExecuteOptions, renames FetchInfiniteQueryPages → InfiniteQueryPages, updates typings/tests for select and staleTime, and wires infinite flows through the new execute surface.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Core Client Implementation packages/query-core/src/queryClient.ts |
Added query and infiniteQuery methods with overloads using QueryExecuteOptions / InfiniteQueryExecuteOptions; infinite flow routed via the new execute surface; updated fetchInfiniteQuery overloads/wrappers. |
Public Types & Typings packages/query-core/src/types.ts |
Added QueryExecuteOptions, exported InfiniteQueryExecuteOptions, introduced/renamed InfiniteQueryPages (was FetchInfiniteQueryPages), and updated related FetchInfiniteQueryOptions and type references. |
Core Tests & Public Helpers packages/query-core/src/__tests__/queryClient.test.tsx, packages/query-core/src/__tests__/queryClient.test-d.tsx |
Tests updated/expanded for static staleTime, infinite-query scenarios, select behavior, and fully-typed usage; type tests updated to reference InfiniteQueryExecuteOptions; added test import usage of exported noop. |
React Type Tests packages/react-query/src/__tests__/infiniteQueryOptions.test-d.tsx, packages/react-query/src/__tests__/queryOptions.test-d.tsx |
Added/updated type assertions validating select behavior across useInfiniteQuery, useSuspenseInfiniteQuery, infiniteQuery, and fetchInfiniteQuery/fetchQuery (select ignored for fetch variants). |
Vue Integration packages/vue-query/src/queryClient.ts |
Added query and infiniteQuery overloads (plain and MaybeRefDeep variants) delegating to super with cloneDeepUnref; type signatures updated to match core execute-option types. |
Changeset .changeset/famous-owls-battle.md |
Package bumps for @tanstack/react-query, @tanstack/query-core, @tanstack/vue-query; note about renamed imperative methods. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant Caller as Caller
participant QClient as QueryClient
participant Executor as Execute Core
participant Cache as Cache / Network
participant Selector as Select (optional)
Caller->>QClient: query(opts) / infiniteQuery(opts)
QClient->>Executor: delegate(QueryExecuteOptions / InfiniteQueryExecuteOptions)
Executor->>Cache: fetch raw TQueryData or pages
Cache-->>Executor: raw TQueryData or pages
alt select provided
Executor->>Selector: apply select(raw data/pages)
Selector-->>Executor: transformed TData or pages
end
Executor-->>QClient: Promise<TData or InfiniteData>
QClient-->>Caller: resolved data
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
- Pay special attention to:
-
packages/query-core/src/types.ts— new generics and renamed pagination types. -
packages/query-core/src/queryClient.ts— overloads, routing, staleTime/select semantics. -
packages/query-core/src/__tests__/queryClient.test.tsxand.test-d.tsx— expanded runtime and type coverage. - Cross-package typings in
packages/vue-queryand react type tests.
-
Suggested reviewers
- TkDodo
Poem
🐰 I tunneled through types and hopped in delight,
added two paths that now run just right.
Pages bound forward, selects take their cue,
noop waved softly — tests nodded too.
🥕
Pre-merge checks and finishing touches
❌ Failed checks (1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Title check | ❓ Inconclusive | The title 'init query rename and delegation' is vague and generic, using non-descriptive terms that don't clearly convey the main changes (renaming fetchQuery/fetchInfiniteQuery to query/infiniteQuery or the delegation strategy). | Use a more specific title like 'Rename fetchQuery/fetchInfiniteQuery to query/infiniteQuery' or 'Implement simplified imperative query methods' to clearly communicate the primary change. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description check | ✅ Passed | The PR description is comprehensive and follows the template structure with filled-out Changes and Checklist sections, clearly documenting the implementation and confirming testing and changeset generation. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
View your CI Pipeline Execution ↗ for commit bf15113b2ec503d67a659909187148a16afd5af9
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
✅ Succeeded | 1m 45s | View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded | 2s | View ↗ |
☁️ Nx Cloud last updated this comment at 2025-11-27 21:02:53 UTC
More templates
- @tanstack/query-example-angular-auto-refetching
- @tanstack/query-example-angular-basic
- @tanstack/query-example-angular-basic-persister
- @tanstack/query-example-angular-devtools-panel
- @tanstack/query-example-angular-infinite-query-with-max-pages
- @tanstack/query-example-angular-optimistic-updates
- @tanstack/query-example-angular-pagination
- @tanstack/query-example-angular-query-options-from-a-service
- @tanstack/query-example-angular-router
- @tanstack/query-example-angular-rxjs
- @tanstack/query-example-angular-simple
- @tanstack/query-example-react-algolia
- @tanstack/query-example-react-auto-refetching
- @tanstack/query-example-react-basic
- @tanstack/query-example-react-basic-graphql-request
- @tanstack/query-example-chat
- @tanstack/query-example-react-default-query-function
- @tanstack/query-example-react-devtools-panel
- @tanstack/query-example-eslint-legacy
- @tanstack/query-example-react-infinite-query-with-max-pages
- @tanstack/query-example-react-load-more-infinite-scroll
- @tanstack/query-example-react-nextjs
- @tanstack/query-example-react-nextjs-app-prefetching
- @tanstack/query-example-nextjs-suspense-streaming
- @tanstack/query-example-react-offline
- @tanstack/query-example-react-optimistic-updates-cache
- @tanstack/query-example-react-optimistic-updates-ui
- @tanstack/query-example-react-pagination
- @tanstack/query-example-react-playground
- @tanstack/query-example-react-prefetching
- @tanstack/query-example-react-react-native
- @tanstack/query-example-react-router
- @tanstack/query-example-react-rick-morty
- @tanstack/query-example-react-shadow-dom
- @tanstack/query-example-react-simple
- @tanstack/query-example-react-star-wars
- @tanstack/query-example-react-suspense
- @tanstack/query-example-solid-astro
- @tanstack/query-example-solid-basic
- @tanstack/query-example-solid-basic-graphql-request
- @tanstack/query-example-solid-default-query-function
- @tanstack/query-example-solid-simple
- @tanstack/query-example-solid-start-streaming
- @tanstack/query-example-svelte-auto-refetching
- @tanstack/query-example-svelte-basic
- @tanstack/query-example-svelte-load-more-infinite-scroll
- @tanstack/query-example-svelte-optimistic-updates
- @tanstack/query-example-svelte-playground
- @tanstack/query-example-svelte-simple
- @tanstack/query-example-svelte-ssr
- @tanstack/query-example-svelte-star-wars
- @tanstack/query-example-vue-2.6-basic
- @tanstack/query-example-vue-2.7-basic
- @tanstack/query-example-vue-basic
- @tanstack/query-example-vue-dependent-queries
- @tanstack/query-example-vue-nuxt3
- @tanstack/query-example-vue-persister
- @tanstack/query-example-vue-simple
@tanstack/angular-query-experimental
npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9835
@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9835
@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9835
@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9835
@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@9835
@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@9835
@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9835
@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9835
@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@9835
@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@9835
@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9835
@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9835
@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@9835
@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9835
@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9835
@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@9835
@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9835
@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9835
@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@9835
@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9835
commit: bf15113
renames fetchQuery and fetchInfiniteQuery to query and infiniteQuery
sorry the idea was not to rename those, but to add new methods and deprecate the old ones. Otherwise, this would be a breaking change.
Codecov Report
:x: Patch coverage is 75.00000% with 5 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 59.97%. Comparing base (aba3260) to head (bf15113).
Additional details and impacted files
@@ Coverage Diff @@
## main #9835 +/- ##
===========================================
+ Coverage 45.89% 59.97% +14.07%
===========================================
Files 200 129 -71
Lines 8437 5671 -2766
Branches 1940 1544 -396
===========================================
- Hits 3872 3401 -471
+ Misses 4116 1964 -2152
+ Partials 449 306 -143
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
From #9135:
Per default, this should behave like queryClient.fetchQuery does today:
- it respects staleTime (like any good query should)
- it returns a Promise you can await.
fetchQuery is still there, it's just a straight passthough for query now
@coderabbitai full review
✅ Actions performed
Full review triggered.