0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
Commit graph

5,266 commits

Author SHA1 Message Date
Dominik Dorfmeister 🔮
fb6c3fabda
fix(react): switch to export type * (#11228) 2026-08-18 21:20:11 +02:00
Shahid Hassan Ansari
5981771abe
fix(query-core): release the retryer once a mutation settles (#11218)
* fix(query-core): release the retryer once a mutation settles

Mutation.execute() never cleared #retryer after settling, so the settled
retryer's promise kept that mutation's result, variables and context
reachable for as long as the MutationCache retained the Mutation. Mirror
the treatment Query.fetch() received in #11163, guarded by an identity
check so a mutation re-executed from a cache callback keeps its own
retryer.

Releasing the retryer alone would change continue(): a settled mutation
no longer has a retryer to continue, so it would fall through to
execute() and run the mutationFn a second time. Both internal callers
filter on state.isPaused and never reach a settled mutation, but
continue() is reachable directly, so the fallback is now gated on the
mutation still being pending -- the same condition execute() already uses
to detect a restored mutation.

Fixes #11216

* test(query-core): assert the settled retryer is actually released

The previous tests only guarded the continue() gating and passed on main
too, so they did not demonstrate the fix. continue() is the only reader
of #retryer outside execute(): while a settled retryer is still held it
hands back that retryer's promise, which resolves with the raw result it
closed over (or rejects with its error). Both new tests fail on main and
pass with the retryer released.

---------

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 20:59:40 +02:00
Scott Cooper
1f631b3604
perf(query-core): Skip unused query result tracking (#11225)
* perf(query-core): Skip unused query result tracking

QueriesObserver was building tracked results on every update even when there was no combine function to consume them. Skip that work for normal useQueries notifications.

Co-Authored-By: Codex <noreply@openai.com>

* ref(query-core): Reuse combine skip check

Treat a missing combine function as another reason to skip combining. This keeps the notification flow close to the existing code and only defers result tracking.

Co-Authored-By: Codex <noreply@openai.com>

* ref(query-core): Match combine presence check

Use the same truthiness check as combineResult so null and other falsy runtime values follow the existing no-combine behavior.

Co-Authored-By: Codex <noreply@openai.com>

---------

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 18:52:50 +02:00
Dominik Dorfmeister 🔮
294d4e62c4
fix: declaration emit (#11224)
Co-Authored by @artemxknpv
2026-08-18 17:48:33 +02:00
Ben Younes
5199f0884c
fix(vue-query): preserve TQueryKey inference with generic params (#8199) (#10584)
* fix(vue-query): preserve TQueryKey inference with generic params (#8199)

The mapped UseQueryOptions type wrapped queryKey in
MaybeRefDeep<DeepUnwrapRef<TQueryKey>>. The recursive DeepUnwrapRef on a
generic TQueryKey is opaque to TS's homomorphic mapped type inference,
so TQueryKey collapsed to its default (QueryKey) when useQuery was
called from a composable that propagates a generic into the queryKey.

For the queryKey property only, drop DeepUnwrapRef and use a single-
level MaybeRef<TQueryKey> wrap. Inference now binds TQueryKey to the
supplied queryKey shape; queryFn still receives DeepUnwrapRef<TQueryKey>
via the existing mapping for non-queryKey properties.

Co-Authored-By: Ora Studio <noreply@oratelecom.net>

* test(vue-query): strengthen #8199 regression assertion with explicit TData

Per CodeRabbit feedback: bare assertType(useBasket('fruit')) only verified
the call compiled, which would still pass under the old buggy behavior
(TQueryKey collapsing to QueryKey, TData inferred as unknown). Lock the
regression by asserting the propagated TData explicitly.

---------

Co-authored-by: Ora Studio <noreply@oratelecom.net>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 17:44:01 +02:00
Dominik Dorfmeister 🔮
de8218cd1d
chore: react-nodenext integration test (#11223)
* chore: react-nodenext integration test

* fix: nx
2026-08-18 16:17:06 +02:00
Dominik Dorfmeister 🔮
267154cf6b
chore: tsup -> tsdown (#11222)
* chore: tsup -> tsdown

* revert size-limit and fix the build instead

* fix angular and devtools build

* fix nextJs builds

* more solid related things

* fix: import order
2026-08-18 15:19:43 +02:00
hamed-bavar
34f7ceed09
fix(query-core): clear stale select error when observer switches to a query without data (#11161)
* fix(query-core): clear stale select error when observer switches to a query without data

* fix(query-core): reset isPlaceholderData on select-error results

---------

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 10:55:02 +02:00
Lazizbek Ergashev
cb6c9d3725
fix({react,preact}-query): default 'TData' of infinite query options to 'InfiniteData' (#11147)
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 10:51:47 +02:00
Reza Rahemtola
e546d03bef
fix(react-query): remove placeholderData from suspense infinite query (#11144)
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 10:44:27 +02:00
Alexander Kireyev
ba4650c05e
fix(query-core): reset isPlaceholderData when select throws on placeholder data (#11011)
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 10:44:05 +02:00
Lazizbek Ergashev
18c1c1ef94
fix(query-core): reattach 'MutationObserver' to its mutation in 'onSubscribe' (#11172)
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 10:18:59 +02:00
Zelys
6e3d521fe5
fix(types): propagate generic type params to useMutationState select callback (#10373)
* fix(types): propagate generic type params to useMutationState select callback

When TResult is a typed MutationState, the select callback parameter
now receives the correctly typed Mutation instead of the base Mutation type.

Adds a second type param TMutation (defaulting to MutationTypeFromResult<TResult>)
to MutationStateOptions across all five framework adapters. Uses a non-distributive
conditional type to avoid union expansion when TResult is unresolved.

Fixes #9825

* ci: apply automated fixes

* refactor(types): simplify useMutationState cast to mutation as TMutation

Replace the double-cast `(fn as unknown as (m: Mutation) => TResult)(m)`
with the direct `fn(m as TMutation)` across all five framework packages.

The constraint `TMutation extends Mutation<any, any, any, any>` creates
sufficient overlap for the single cast to compile cleanly on TS 5.4–6.0.

* fix(test): reorder imports in useMutationState.test-d.tsx per import/order rule

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(svelte-query): eliminate duplicate MutationTypeFromResult definition

Export MutationTypeFromResult from types.ts so useMutationState.svelte.ts
can import it instead of redefining it. Also normalises the else branch to
plain Mutation, matching every other adapter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 10:02:05 +02:00
Guilherme Rabelo
baa256c0d2
docs(examples): add Next.js App Router optimistic updates example (#10997)
* feat(examples): add Next.js App Router optimistic updates example

* refactor(examples/nextjs-app-optimistic-updates): apply post-review corrections

* refactor(examples/nextjs-app-optimistic-updates): apply post-review corrections

* update deps

* ref: remove other optimistic update examples

* ci: apply automated fixes

---------

Co-authored-by: Guilherme Rabelo <T0006742@randon.com.br>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-18 09:57:04 +02:00
Scott Cooper
5bb089d153
perf(query-core): Reduce observer removal overhead (#11214)
Removing observers copied the full observer list on every unsubscribe, which got expensive when thousands of components shared a query. Splice the existing list in place instead.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 09:38:08 +02:00
Gihyeon Jeong / 정기현
8582702152
refactor(eslint-plugin-query): remove unused ast-utils helpers (#11115)
* refactor(eslint-plugin-query): remove unused ast-utils helpers

Remove five unused helpers from the ASTUtils object in ast-utils.ts:
getNestedIdentifiers, getNestedReturnStatements, getClosestVariableDeclarator,
mapKeyNodeToText and mapKeyNodeToBaseText.

None are referenced by any rule or other module, and ASTUtils is not part of
the package's public API (it is not exported from index.ts). knip does not flag
them because ASTUtils is exported as a single object, so member-level dead code
slips past it.

All 1709 tests pass and ast-utils.ts line coverage rises from 41% to 95%.

* chore: add changeset for unused ast-utils helper removal

---------

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 09:37:41 +02:00
Scott Cooper
01a02bfad3
perf(query-core): Deduplicate tracked query properties (#11215)
* perf(query-core): Deduplicate tracked query properties

Each accessed useQueries result fans the same property out to every observer, making ordinary result mapping quadratic.

Track which properties have already been synchronized during the current result pass. This keeps the #7000 behavior while dropping the 10,000-result tracking benchmark from about 699 ms to under 1 ms locally.

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* test(query-core): Cover repeated property tracking

Extend the existing tracking assertion to cover the same property being read from a second result.

Co-Authored-By: OpenAI Codex <noreply@openai.com>

---------

Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 09:37:33 +02:00
palkim
47d49d31aa
fix(solid-query): resolve query client outside memos (#10571)
* fix(solid-query): resolve query client outside memos

* fix(solid-query): resubscribe client counters

* test(solid-query): assert client subscription cleanup

---------

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-18 09:22:07 +02:00
Dominik Dorfmeister 🔮
279bb5508b
chore: update to ts 7 and move cut-off to 5.6 (#11212)
* update to ts 7 and move cut-off to 5.7

* changeset

* fix: use typescript v6 with tsup

* ci: apply automated fixes

* ref: update sveltejs/package

* ref: make ts6 the default typescript

* fix: lit build

* effing tsup

* move ignoreDeprecations to solid tsup config

* move ignoreDeprecations to relevant tsup configs

* better lit fix

* restore vue queryClient

* Revert "restore vue queryClient"

This reverts commit 4f95fc918a.

* fix things

* ignore devDep ordering

* vue needs to use ts6

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-17 22:50:18 +02:00
Dominik Dorfmeister 🔮
dce04b5c5a
chore: Add AI guidelines to contribution guide (#11213) 2026-08-17 20:14:36 +02:00
Abdul Wasay
3bc8edfa01
fix(eslint-plugin-query): avoid prototype property false-positives in no-unstable-deps (#11188)
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-17 19:49:57 +02:00
Lazizbek Ergashev
5633820181
fix(lit-query): add DataTag to the queryKey returned by infiniteQueryOptions (#11146)
* fix(lit-query): add DataTag to the queryKey returned by infiniteQueryOptions

* test(lit-query): cover error brand and callback updater for infiniteQueryOptions

---------

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-17 14:54:22 +02:00
Shelley Vohr
4a9bef6cf1
fix(query-core): release the retryer once a fetch settles (#11163)
A query kept its last retryer for life, and the settled promise holds that
fetch's raw result: a second full copy of the data once a refetch has been
structurally shared into state.data, and still held after reset() or removal.

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-17 14:45:44 +02:00
Manan Telrandhe
6613753cbe
docs(examples): use webpack in Next.js examples for StackBlitz compatibility (#11110) 2026-08-17 14:44:53 +02:00
Dominik Dorfmeister 🔮
326aaf1333
fix(query-core): resetQueries now preserves the queries matched before query.reset() changes their state. (#11211)
fix: resetQueries
2026-08-17 14:28:17 +02:00
Ciarán Curley
c6fc17cfad
feat(query-core): add simplified query methods (#10658)
* feat(query-core): add simplified query methods

* tests: stage adapter queryOptions coverage for new query methods

* ref: disallow `enabled`

* ci: apply automated fixes

* remove outdated test

* test(lit): remove other outdated test

---------

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-17 13:59:13 +02:00
Amariah Abishai
bef4bc780c
fix(query-core): resolve suspense when query data is set programmatically (#11036)
* fix(query-core): resolve suspense when query data is set programmatically

When useSuspenseQuery is used and setQueryData populates the cache
while a fetch is in-flight, the suspense boundary stays stuck on the
original fetch promise. This prevents streamedQuery and manual cache
updates from releasing suspense.

Modify fetchOptimistic in queryObserver to use Promise.race between
the fetch promise and a cache subscriber that listens for 'updated'
events. When data appears in the cache via setQueryData or a streamed
chunk, the race resolves immediately without aborting the fetch.
This allows the suspense boundary to release and show the available
data while the fetch continues in the background.

Closes #10924

Co-authored-by: atlarix-agent <agent@atlarix.dev>

* chore: add changeset for suspense setQueryData fix

Co-authored-by: atlarix-agent <agent@atlarix.dev>

* fix(query-core): prevent subscription leak in fetchOptimistic on fetch rejection

unsubscribe() was only called in the .then() success path. If
query.fetch() rejected before the cache subscriber resolved the race,
the subscription leaked — staying registered on QueryCache indefinitely
and checking a stale queryHash on every 'updated' event.

Use .finally() to ensure unsubscribe() runs on both success and
rejection, preserving the original promise type through the chain.

Co-authored-by: atlarix-agent <agent@atlarix.dev>

* fix(query-core): settle floating promise in fetchOptimistic and add undefined test

- Resolve the subscriber promise when fetch succeeds so both branches
  of Promise.race always settle, avoiding a permanently pending promise
- Move resolution into .then() rather than .finally() so fetch failures
  still propagate through Promise.race rejection
- Add test: setQueryData with undefined must NOT release suspense,
  documenting the query.state.data !== undefined guard

Co-authored-by: atlarix-agent <agent@atlarix.dev>

* Update packages/query-core/src/queryObserver.ts

* test(queryObserver): cover cached data resolution

---------

Co-authored-by: DeepSeek V4 Pro agent <agent@atlarix.dev>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-17 10:19:39 +02:00
Alexander Kolesnik
5448063f82
fix(query-core): ignore a retained thenable callback invoked after settling (#11128)
* test(query-core): add unit tests for thenable

* fix(query-core): ignore a retained thenable callback invoked after settling

* chore: add changeset

* ci: apply automated fixes

---------

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-17 09:52:21 +02:00
Yogesh Kumar
1a779e585d
fix(scripts): make the docs link check work on Windows (#11181)
'relativeLinkExists' builds the target path with 'path.resolve', which
uses the platform separator, but then matches it against '/examples/'
and rewrites it with a regex written in forward slashes.

On Windows the resolved path uses backslashes, so neither pattern
matches. Every documentation link that points at an example is looked up
as a markdown file under 'docs/framework/<name>/examples/' instead of a
directory under 'examples/<name>/', and 'pnpm test:docs' reports 27
broken links that are fine on CI.

Normalize the separators before the two comparisons. Node accepts
forward slashes on Windows, so the resolved path stays usable.

Co-authored-by: Yogesh Kumar <webdev1@futeservices.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-17 09:16:11 +02:00
SiHyunLee
bcb030bfbb
docs: fix in-page anchor links to match the docs site's slug format (#11162) 2026-08-17 09:09:57 +02:00
Wonsuk Choi
6423f9eb9e
docs(vue-query/reference): hide React-only 'React.use()' mention from useInfiniteQuery (#11203) 2026-08-17 04:24:43 +09:00
Wonsuk Choi
0785da5510
docs(vue-query/guides/ssr): fix 'queryKey' to use array form (#11202) 2026-08-17 03:24:57 +09:00
hamed-bavar
bdfbeadb70
docs(vue-query/guides/suspense): update example to v5 object syntax (#11159)
docs(vue-query): update suspense guide example to v5 object syntax
2026-08-17 03:08:59 +09:00
Wonsuk Choi
b36374c150
docs(react-query/reference): fix 'queryClient' nesting in 'HydrationBoundary' options (#11201) 2026-08-17 02:45:36 +09:00
Wonsuk Choi
4ace03b55a
docs(react-query/reference): remove stale 'suspense' references left over from the v5 suspense split (#11200) 2026-08-17 02:44:07 +09:00
Wonsuk Choi
4446c3a1cb
docs(config.json): add 'Preact Reference' index entry to API Reference sidebar (#11198) 2026-08-17 00:08:58 +09:00
Wonsuk Choi
ed1c1bd34f
docs(reference): remove redundant page title heading from InfiniteQueryObserver, QueriesObserver, and QueryClient (#11197) 2026-08-16 23:26:46 +09:00
Wonsuk Choi
f1a435977f
docs: regenerate reference docs to drop redundant TypeDoc page title heading (#11196) 2026-08-16 22:08:19 +09:00
Wonsuk Choi
ed5e1d3a87
chore(generate-docs): hide redundant TypeDoc page title heading (#11194) 2026-08-16 21:53:52 +09:00
Wonsuk Choi
3f9d11b814
docs(config.json): drop redundant 'Functions /' prefix from svelte and angular sidebar labels (#11193) 2026-08-16 19:11:49 +09:00
Wonsuk Choi
9ad475e0ac
docs(config.json): register missing svelte API reference functions in sidebar (#11192) 2026-08-16 18:49:06 +09:00
Wonsuk Choi
7d4b6ed52e
docs(config.json): register missing angular API reference functions in sidebar (#11191) 2026-08-16 18:25:52 +09:00
Wonsuk Choi
a9f416bbae
docs: regenerate reference docs to fix stale content and Preact source links (#11189) 2026-08-16 17:58:55 +09:00
Wonsuk Choi
c5f29995fe
docs(solid-query/useQuery): document 'throwOnError' default value and its exceptions (#11170)
* docs(solid-query/useQuery): document 'throwOnError' default value

* docs(solid-query/useQuery): document SSR and 'suspense' exceptions to 'throwOnError' default
2026-08-16 14:06:04 +09:00
Wonsuk Choi
159982c80b
docs(react-query/useQuery): document 'throwOnError' default value (#11156)
* docs(react-query/useQuery): document 'throwOnError' default and its absence in suspense hooks

* docs(react-query/useQuery): use framework-agnostic wording for suspense throwOnError note

* docs(react-query/useQuery): remove inaccurate suspense-mode throwOnError note
2026-08-12 10:03:07 +09:00
Alem Tuzlak
46d7f02f1c
docs: use the dynamic README header endpoint (#11136)
* docs: use the dynamic README header endpoint

* docs: add README header banners to the framework adapter packages
2026-08-03 13:43:19 +02:00
Melih Arık
31c7f374e2
docs(angular-query): fix invalid imports and syntax error in guide examples (#11090)
* docs(angular-query): fix three broken examples in the guides

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-02 17:34:23 +09:00
SiHyunLee
96fbd7d38e
docs(CONTRIBUTING): remove stale gitpod one-click setup section (#11096) 2026-08-02 16:17:51 +09:00
SiHyunLee
6efc619123
docs(CONTRIBUTING): replace 'npm run test' and 'npx nx' commands with 'pnpm' equivalents (#11095)
docs(CONTRIBUTING): replace 'npm run test' and 'npx nx' command with 'pnpm' equivalents
2026-08-02 16:07:27 +09:00
Wonsuk Choi
9d24c45545
test(react-query/useQuery.promise): unskip 'cancelQueries' while suspending test by keeping 'queryFn' in-flight (#10910)
* test(react-query/useQuery.promise): unskip 'cancelQueries' while suspending test by keeping 'queryFn' in-flight

* test(react-query/useQuery.promise): clarify why 'sleep' is extended in cancel-while-suspending test
2026-07-29 10:03:48 +09:00