0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-18 19:33:22 +00:00
Commit graph

72 commits

Author SHA1 Message Date
Ciarán Curley
e6748265c8
React: update usePrefetchQuery to use new methods, plus react adaptor tests and docs (#10668)
* feat(react-query): update usePrefetchQuery to use new imperitive methods plus tests

* docs(react-query): new docs for usePrefetchQuery

* Update .changeset/warm-candies-like.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/react-query/src/usePrefetchInfiniteQuery.tsx

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>

* Update packages/react-query/src/usePrefetchQuery.tsx

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-20 18:35:32 +02:00
Dominik Dorfmeister 🔮
1ef42087c9
ref: remove experimental_prefetchInRender (#11221) 2026-08-20 11:32:10 +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
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
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
Samuel Wai Weng Yong
f6cf12002a
docs({react,solid}-query): add missing 'errorUpdateCount' to 'useQuery' return signature (#11041)
* docs(react-query): add missing errorUpdateCount to useQuery return signature

* docs(react-query): move errorUpdateCount after errorUpdatedAt

* docs(react-query): keep 'errorUpdateCount' before 'errorUpdatedAt' to preserve alphabetical order

---------

Co-authored-by: Wonsuk Choi <sukvvon@gmail.com>
2026-07-13 03:28:00 +09:00
Jonghyeon Ko
1f84256a2e
docs: document the select typing caveat for parallel-queries hooks (#10984)
Inlining a `select` on a query object passed to `useQueries` /
`useSuspenseQueries` can't infer its `data` argument from the sibling
`queryFn` and falls back to `unknown` — a known TypeScript limitation
(TanStack/query#6556).

Document the two workarounds (annotate the `select` parameter, or define
the query with the `queryOptions` helper) in the React docs, and add type
tests guarding the behavior. Scoped to React for an easier review; the
other framework adapters can follow the same pattern in separate PRs.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 15:30:15 +02:00
Dominik Dorfmeister 🔮
6540a4126b
feat(core): callback for retryOnMount (#10515)
* feat(core): callback for retryOnMount

* ci: apply automated fixes

* fix: vue

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-04-23 14:45:49 +02:00
Daniel Bondarenko
4e8be3f46f
docs: clarify that failureCount starts at 0 in retry callback (#10031)
Added clarification that failureCount parameter in the retry callback
function starts at 0 for the first retry attempt, not 1.

Fixes #10017
2026-01-16 11:24:55 +01:00
Talgat Minigaliev
bdec357b9e
docs: Modify onMutate signature to add context parameter (#9982)
Updated the onMutate function signature to include context.
2025-12-27 12:31:21 +01:00
Lachlan Collins
5ad78fc4ad
docs: correct local relative links (#9947)
* docs: correct local relative links

* Update links

* Slight tweaks

* String
2025-12-05 22:39:25 +11:00
Sarah
7783a7ae49
docs: add community resources page (#9831)
* add community resources page

* update link for blog posts

* update community resource links

* rm vue community section

* update old links

* fix community resource link
2025-11-06 12:59:56 +01:00
Josh
a2151d28e1
feat(query-core): add context to mutationfn & mutation callbacks (#9615)
* feat(query-core): add context to mutationfn

Co-Authored-By: travikk <627275+travikk@users.noreply.github.com>

* fix(query-core): mutation onSuccess scope param should also be undefined

Co-Authored-By: travikk <627275+travikk@users.noreply.github.com>

* feat: add scope deprecate context on mutation state

* feat(query-core): add mutation context to all mutation callbacks

* chore: pr amends

Co-Authored-By: Dominik Dorfmeister <1021430+TkDodo@users.noreply.github.com>

* test(unit): update to handle context in mutation callbacks

* chore: rename to onMutateResult

* chore: revert context deprecation on MutationState

---------

Co-authored-by: travikk <627275+travikk@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <1021430+TkDodo@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-09-16 10:22:43 +02:00
Jake Teton-Landis
a0b96db937
feat(query-core): add timeoutManager to allow changing setTimeout/setInterval (#9612)
* add timeoutManager class

* add additional types & export functions

* convert all setTimeout/setInterval to managed versions

* tweaks

* add claude-generated tests

* tests

* revert changes in query-async-storage-persister: no path to import query-core

* re-export more types

* console.warn -> non-production console.error

* query-async-storage-persister: use query-core managedSetTimeout

* pdate pnpm-lock for new dependency edge

* sleep: always managedSetTimeout

* remove managed* functions, call method directly

* remove runtime coercion and accept unsafe any within TimeoutManager class

* cleanup; fix test after changes

* name is __TEST_ONLY__

* notifyManager: default scheduler === systemSetTimeoutZero

* Improve TimeoutCallback comment since ai was confused

* remove unnecessary timeoutManager-related exports

* prettier-ify index.ts (seems my editor messed with it already this pr?)

* continue to export defaultTimeoutProvider for tests

* oops missing import

* fix: export systemSetTimeoutZero from core

* ref: use notifyManager.schedule in createPersister

because it needs to work with whatever scheduleFn we have set there

* ref: move provider check behind env check

* docs

* doc tweaks

* doc tweaks

* docs: reference timeoutManager in discussion of 24 day setTimout limit

* Apply suggestion from @TkDodo

* Apply suggestion from @TkDodo

* chore: fix broken links

* docs: syntax fix

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-09-05 13:37:09 +02:00
우혁
428c19fa33
docs: update mutation status type (#9595)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-30 14:47:27 +09:00
우혁
2a8ba49919
docs: remove unnecessary trailing comma (#9594)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-30 14:44:30 +09:00
우혁
54efe225b6
docs: fix type definitions in useQuery options (union, parameters, extra parentheses) (#9596)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-30 14:36:19 +09:00
TkDodo
f1e608bcac docs: update community resources 2025-08-18 12:19:08 +02:00
Sajad Torkamani
c8322d96b1
docs: add missing period (#9509)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-07-31 20:35:25 +02:00
Lachlan Collins
9133c101c8
chore: manually update dependencies (#9464)
* chore: update packages

* Fix typescript-eslint type mismatch

* Pin vitest

* Update prettier
2025-07-19 11:23:28 +10:00
Dominik Dorfmeister
23c8908086
feat(core): QueryObserver returns isEnabled flag (#9408)
* feat(core): QueryObserver returns isEnabled flag

* test: solid and svelte
2025-07-11 18:57:28 +02:00
우빈
f3cbfc51da
feat(react-query): add mutationOptions (#8960)
* feat(react-query): add mutationOptions

* test(react-query): add DataTag test case

* fix(react-query): remove unnecessary types from mutation

* fix(react-query): remove unncessary type overload

* chore(react-query): add mutationOptions to barrel file

* fix(react-query): fix test eslint issue

* docs(react-query): add more examples

* test(react-query): add more test cases

* chore(react-query): Change mutaitonKey to required

* fix(react-query): fix test code type error

* test(react-query): add testcase when used with other mutation util

* fix(react-query): fix error test code and avoid use deprecateed method

* fix(react-query): fix error test code and avoid use deprecateed method

* fix(react-query): fix import detect error

* fix(react-query): fix import detect error

* fix(react-query): add function overload

* test(react-query): fix mutation options test code

* Update docs/framework/react/typescript.md

* Update docs/framework/react/reference/mutationOptions.md

* Update docs/framework/react/typescript.md

* fix: update mutationOptions type definition to allow optional mutationKey with restricting filter when mutationKey wasn't passed

* ci: apply automated fixes

* chore: add Nick-Lucas as co-author

Co-authored-by: Nick Lucas <8896153+Nick-Lucas@users.noreply.github.com>

* test(react-query): fix test code and add used with useMutation without mutationKey

* Update packages/react-query/src/__tests__/mutationOptions.test-d.tsx

* docs: add mutationOptions to sidebar config

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Nick Lucas <8896153+Nick-Lucas@users.noreply.github.com>
2025-07-09 16:59:41 +02:00
Braden Wong
dfbda9de66
refactor(types): revert narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)" (#9251)
This reverts commit 982f6ca607.
2025-06-05 15:04:37 +02:00
Braden Wong
982f6ca607
refactor(types): narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)
* refactor: narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void

Previously, the `onSuccess`, `onError`, `onMutate`, and `onSettled` callbacks were typed as `() => Promise<unknown> | unknown`. While `unknown` is technically valid, it implies that the return value might be used, assigned, or further processed. However, throughout the codebase, these callbacks are invoked solely for their side effects, and their return values are always ignored. Narrowing the type to `Promise<void> | void` makes this intent explicit, clarifies that any return value will be discarded, and prevents misleading type signatures that suggest otherwise.

This commit narrows their types to `() => Promise<void> | void`, which more accurately reflects their intended use.

* docs: update callback return types to Promise<void> | void in mutation-related documentation

This commit refines the documentation for mutation-related callbacks (`onSuccess`, `onError`, `onSettled`, and `onMutate`), changing their return types from `Promise<unknown> | unknown` to `Promise<void> | void`.
2025-06-02 18:09:24 +02:00
Dominik Dorfmeister
b475d21568
feat(core): staleTime: 'static' (#9139)
* feat(core): StaleTime.Static

* fix: consider StaleTime.Static for invalidation

previously, it didn't matter if we included `stale: true` or not in the filters for refetch, because marking things with query.invalidate() would set them all to stale anyway.

Now, queries with StaleTime.Static will be marked as `invalidated`, but still shouldn't be refetched. The `isStale` filter logic accounts for that, so we have to include it in the filters

* fix: isStale order check

check for observers first because they contain the source of truth calculated with `isStaleByTime`, and it also takes enabled into account

* fix: isStaleByTime logic

we have to check for undefined data first, because queries without data are really always stale; then, the next check must be against StaleTime.Static, because queries that are marked as invalidated are still not stale, even if they are static.

* tests

* fix: type issue in react

* fix: make sure invalidation _always_ only refetches stale queries

this ensures we never refetch Static queries

* fix: never refetch static queries

* fix: make sure we don't refetchOn... for StaleTime.Static even when 'always' is set

* docs: StaleTime.Static

* ref: switch to 'static' string

* docs
2025-05-29 11:40:52 +02:00
Tanner Linsley
afc6302dbf docs: fix links
commit 113eb6ba963534fe80b3e96193d767bf769c8bff
Author: Tanner Linsley <tannerlinsley@gmail.com>
Date:   Fri May 23 23:16:11 2025 -0600

    docs: fix: only transform generated reference

commit d1d084ed9026e31ba746e1bb87d5c19183a7d148
Author: Tanner Linsley <tannerlinsley@gmail.com>
Date:   Fri May 23 23:12:07 2025 -0600

    docs: fix broken links

commit 0df59ea7d8afb16be86ae917fc46900b6e999351
Author: Tanner Linsley <tannerlinsley@gmail.com>
Date:   Fri May 23 15:54:19 2025 -0600

    fix: rewrite type doc links to be directory-relative

commit 81e4c71f1c9250005f164b7e585837ee0ad14e23
Author: Tanner Linsley <tannerlinsley@gmail.com>
Date:   Fri May 23 15:14:51 2025 -0600

    fix: initial fix for ./ => ../
2025-05-24 00:47:55 -06:00
Giorgio Polvara
376bbd25a3
docs: fix documentation on status for suspense hooks (#9008)
* fix documentation on status for suspense hooks

* Fix formatting in useSuspenseInfiniteQuery.md
2025-04-12 22:05:20 +02:00
Mohammad Reza Badri
0e1d866dfe
docs: correct missing closing quote in networkMode option (#8965) 2025-04-07 14:21:06 +02:00
Clarence
24c80558c4
docs(react-reference): fixed cancellation typo (#8883) 2025-03-31 11:10:17 +02:00
TkDodo
4b7fd0e836 docs: fix internal links 2025-03-18 09:45:11 +01:00
Harry
8bfa77b525
docs(react-query): fix incorrect link in documentation (#8699)
* docs(react-query): fix incorrect paths in documentation
The documentation contained incorrect file paths.
Fixed the incorrect paths to match the actual directory structure.

* docs(react-query): fixed incorrect relative path (./ -> ../)
2025-03-08 13:08:47 +01:00
Joseph Markus
67e52cf889
docs: Fix 404 link for Query Keys in useQuery.md (#8769)
Current link takes to https://tanstack.com/query/latest/docs/framework/guides/query-keys which is a 404
2025-03-07 19:19:55 +01:00
Julius Marminge
6ca0eb776c
fix: no hydration when new promise comes in (#8383)
* add failing repro test

* update assertinos

* add logg

* ehm - maybe fix?

* rm -only

* make example

* upd

* ad debug logs

* more debugging

* push

* maybe???

* rm log

* revert

* fix: ?

* fix: check for pending status again

otherwise, we risk including promises that happen because of background updates (think persistQueryClient)

* fix: clear serverQueryClient between "requests"

otherwise, we are re-using the cache and the query won't be in "pending" state the second time around

* chore: remove logs

* rethrow next build error

* kick off ci again

* add `shouldRedactError` option

* pluralize

* docs

* chore: more memory

* chore: revert more memory

* don't compare statuses if they don't exist

* ci: apply automated fixes

* lint

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-17 13:52:17 +01:00
Alex Errant
bb25d06980
docs: better document throwOnError's default (#8581)
* better document `throwOnError`'s default

* delete unnecessary defaultOptions doc
2025-02-16 16:26:57 +01:00
Dominik Dorfmeister
e2bc2165fa
feat(react-query): allow useQuery and useQueries to unsubscribe from the query cache with an option (#8348)
* feat(react-query): allow useQuery and useQueries to unsubscribe from the query cache with an option

* test: subscribed

* fix: revert calling getOptimisticResult later

* docs(react): update the react-native.md section (#8506)

* update the doc

* update the doc

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>

* docs: reference

---------

Co-authored-by: Florian De la comble <f.delacomble@gmail.com>
2025-01-08 15:17:08 +01:00
Pierre Spring
18d81b96d5
docs: Update infiniteQueryOptions.md (#8447)
Fix copy/pasted typo.
2024-12-23 14:42:36 +01:00
gnerkus
a76ac59e97
docs(useQuery): add more info to description of staleTime field of query options (#8448) 2024-12-18 10:13:29 +01:00
최준영
665e747c6a
docs: Fix typo in useMutation.md (#8397)
Fix typo in useMutation.md
2024-12-07 09:00:19 +01:00
Jérémy Barbet
71c5f8801d
docs: sentence wording (#8106) 2024-10-01 20:09:09 +02:00
Alex / KATT
18953be6f6
feat: add support for React.use() (#7988)
* let’s do it again

* fix test group

* maybe

* mkay

* cool

* rm console.logs

* mkay

* mkay

* fix(vue-query): invalidate queries immediately after calling `invalidateQueries` (#7930)

* fix(vue-query): invalidate queries immediately after call `invalidateQueries`

* chore: recovery code comments

* release: v5.53.2

* docs(vue-query): update SSR guide for nuxt2 (#8001)

* docs: update SSR guide for nuxt2

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* thenable

* mkay

* Update packages/react-query/src/__tests__/useQuery.test.tsx

* mkay

* mkay

* faster and more consistent

* mkay

* mkay

* mkay

* mkay

* mkay

* fix unhandled rejections

* more

* more

* mkay

* fix more

* fixy

* cool

* Update packages/react-query/package.json

* fix: track data property if `promise` is tracked

if users use the `promise` returned from useQuery, they are actually interested in the `data` it unwraps to. Since the promise doesn't change when data resolves, we would likely miss a re-render

* Revert "fix: track data property if `promise` is tracked"

This reverts commit d1184babd1.

* add test case that @tkdodo was concerned about

* tweak

* mkay

* add `useInfiniteQuery()` test

* consistent testing

* better test

* rm comment

* test resetting errror boundary

* better test

* cool

* cool

* more test

* mv cleanup

* mkay

* some more things

* add fixme

* fix types

* wat

* fixes

* revert

* fix

* colocating doesn’t workkk

* mkay

* mkay

* might work

* more test

* cool

* i don’t know hwat i’m doing

* mocky

* lint

* space

* rm log

* setIsServer

* mkay

* ffs

* remove unnecessary stufffff

* tweak more

* just naming and comments

* tweak

* fix: use fetchOptimistic util instead of observer.fetchOptimistic

* refactor: make sure to only trigger fetching during render if we really have no cache entry yet

* fix: move the `isNewCacheEntry` check before observer creation

* chore: avoid rect key warnings

* fix: add an `updateResult` for all observers to finalize currentThenable

* chore: logs during suspense errors

* fix: empty catch

* feature flag

* add comment

* simplify

* omit from suspense

* feat flag

* more tests

* test: scope experimental_promise to useQuery().promise tests

* refactor: rename to experimental_prefetchInRender

* test: more tests

* test: more cancelation

* fix cancellation

* make it work

* tweak comment

* Update packages/react-query/src/useBaseQuery.ts

* simplify code a bit

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

* refactor: move experimental_prefetchInRender check until after the early bail-out

* fix: when cancelled, the promise should stay pending

* test: disabled case

* chore: no idea what's going on

* refactor: delete unnecessary check

* revert refactor i did for cancellation when we wanted it to `throw`

* add docs

* align

* tweak

* Update docs/reference/QueryClient.md

* Update docs/framework/react/reference/queryOptions.md

---------

Co-authored-by: Alex Liu <dsa1314@gmail.com>
Co-authored-by: Tanner Linsley <tannerlinsley@users.noreply.github.com>
Co-authored-by: Damian Osipiuk <osipiukd+git@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2024-10-01 17:39:37 +02:00
lami (laurent lahmy)
c12587a19a
Update useQueries.md (#8097)
fix typo
2024-09-30 10:53:21 +02:00
baeharam
9da00d610a
docs(react-query): fix queryClient description of useMutation and use… (#8077)
* docs(react-query): fix queryClient description of useMutation and useQuery

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-21 15:52:41 +02:00
Romain Trotard
804357b935
docs: Add known limitation about cancellation with suspense hooks (#7958)
* docs: Add known limitation about cancellation with suspense hooks

* 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>
2024-08-27 18:23:55 +02:00
wing
0c671eecb7
fix(query-core): allow function value of notifyOnChangeProps query option to return undefined (#7441)
* fix(query-core): allow function value of `notifyOnChangeProps` query option to return `undefined`

`undefined` is a valid return value for the function value of `notifyOnChangeProps`. See linked issue for more details.

Fixes #7426.

* docs(react-query): update signature of `useQuery`'s `notifyOnChangeProps` option

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2024-07-18 08:52:20 +02:00
Dominik Dorfmeister
46359542f0 chore: prettier 2024-07-15 17:20:41 +02:00
Kier Borromeo
369d826066
docs: access latest data for useMutationState (#7738) 2024-07-15 16:15:02 +02:00
87xie
70c40e7876
docs(react-query): Correct links in usePrefetchQuery (#7658) 2024-07-03 18:54:56 +10:00
Julius Marminge
8cbe7d5dc1
feat(hydration): dehydrate.serialize and hydrate.deserialize (#7615)
* add transformData to restore resolved prefetches

* add failing test

* fix test

* remove transformPromise

* fix

* rev

* rm log

* fix test

* add another test

* serialize/deserialize

* chore: docs + minor refactor

* indentation

* chore: prettier

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2024-06-29 07:10:45 +02:00
Alexander Svendsen
87c8e01e4c
docs: remove suspense reference to useQuery (#7640)
useQuery has no suspense option
2024-06-28 14:41:20 +02:00