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

68 commits

Author SHA1 Message Date
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
3270e09ac0
docs(reference/QueryCache): correct the 'find' and 'findAll' options to match their filter types (#10884) 2026-06-04 20:35:35 +09:00
Minh Lê
525e3168b5
docs(reference/QueryCache): use the v5 filters-object form in 'find' and 'findAll' examples (#10873)
docs(query): use the v5 filters-object form in QueryCache examples
2026-06-04 19:49:06 +09:00
0Jaemin0
98fd431f7c
docs(reference/QueryClient): clarify query client query methods (#10725)
* docs(reference): clarify query client query methods

* Apply suggestions from code review

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

---------

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-05-22 18:07:42 +02:00
Jan Aagaard
7d881354ff
docs: Update the documentation for gcTime in setQueryData (#10559)
Clarified the behavior of gcTime in setQueryData.

https://bsky.app/profile/tkdodo.eu/post/3mk2z7ur7kc2m
2026-04-22 12:56:26 +02:00
Dominik Dorfmeister 🔮
6fa901b97a
feat/environmentManager (#10199)
* environmentManager

* ci: apply automated fixes

* ref: environmentManager

* fix: adapt tests to not using isServer anymore

* ref: revert to main

* make tests better

* Create moody-mails-deliver.md

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-03-18 12:52:51 +01:00
Pavan Shinde
a25e99d6cb
docs: fix TanStack capitalization (#10128) 2026-02-13 12:07:24 +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
ahmethos
eb559a66dc
fix(streamedQuery): fall back to initialValue when stream yields no values (#9876)
* fix(streamedQuery): fall back to initialValue when stream yields no values

Add failing test for empty streams and update implementation to avoid returning undefined.
Includes changeset for patch release.

* chore: address review nitpicks (JSDoc + test cleanup)

* docs: note that initialValue is returned when the stream yields no values

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-11-16 19:19:44 +01: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
Dominik Dorfmeister
b25412a9e3
ref: rename queryFn to streamFn in streamedQuery (#9606)
* ref: rename queryFn to streamFn in streamedQuery

this avoids the weirdly double-nested queryFn naming

* chore: docs

* fix: docs
2025-09-04 11:19:15 +02:00
marco gobbi
8f24580fda
feat(query-core): add custom reducer support to streamedQuery (#9532)
* feat(query-core): add custom reducer support to streamedQuery

Replace maxChunks parameter with flexible reducer function that delegates
data aggregation to consumer code. This provides full control over how
streamed chunks are combined into the final data structure.

Add support for custom placeholderData that works seamlessly with the
reducer function, allowing initialization of complex data types beyond
simple arrays.

https://github.com/TanStack/query/discussions/9065

BREAKING CHANGE: The maxChunks parameter has been removed from streamedQuery.
Use a custom reducer function to control data aggregation behavior instead.

* ci: apply automated fixes

* feat(query-core): require initialValue when using custom reducer in streamedQuery

Add type safety by making initialValue mandatory when providing a custom
reducer function. This prevents runtime errors and ensures proper data
initialization for custom data structures beyond simple arrays.

Use conditional types to enforce the relationship between reducer and
initialValue parameters, maintaining backward compatibility for simple
array-based streaming while requiring explicit initialization for
custom reducers.

BREAKING CHANGE: When using a custom reducer function with streamedQuery,
the initialValue parameter is now required and must be provided.

* feat(query-core): require initialValue when using custom reducer in streamedQuery

Add type safety by making initialValue mandatory when providing a custom
reducer function. This prevents runtime errors and ensures proper data
initialization for custom data structures beyond simple arrays.

Use conditional types to enforce the relationship between reducer and
initialValue parameters, maintaining backward compatibility for simple
array-based streaming while requiring explicit initialization for
custom reducers.

BREAKING CHANGE: When using a custom reducer function with streamedQuery,
the initialValue parameter is now required and must be provided.

* feat(query-core): require initialValue when using custom reducer in streamedQuery

Add type safety by making initialValue mandatory when providing a custom
reducer function. This prevents runtime errors and ensures proper data
initialization for custom data structures beyond simple arrays.

Use conditional types to enforce the relationship between reducer and
initialValue parameters, maintaining backward compatibility for simple
array-based streaming while requiring explicit initialization for
custom reducers.

BREAKING CHANGE: When using a custom reducer function with streamedQuery,
the initialValue parameter is now required and must be provided.

* removed personal vscode workspace file

* updated documentation

* fix(docs): clarify reducer function description in streamedQuery documentation

* ci: apply automated fixes

* fix(tests): Code Review :: update streamedQuery tests to use correct initialValue type

---------

Co-authored-by: gobbimar <marco.gobbi@adidas.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-04 11:03:41 +02:00
Vlad Kovechenkov
f97d7258a0
docs: mention second parameter for cancelQueries (#9597)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-09-02 12:08:19 +09: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
Dominik Dorfmeister
9973e0f1d8
feat: maxChunks (#9184) 2025-05-24 09:22:00 +02:00
autofix-ci[bot]
20c36c8bf3
ci: apply automated fixes 2025-05-24 06:48:59 +00: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
Dominik Dorfmeister
ff0131b142
feat(query-core): refetchMode “replace” for streamedQuery (#9092)
* refetchmode replace

* feat: refetchMode replace for streamedQuery

* test: should allow arrays
2025-05-01 15:24:59 +02:00
Emma Segal-Grossman
8c7df6369f
docs: Fix broken links on QueryCache reference page (#9033)
* Fix broken link to TkDodo's Blog page from QueryCache page

It looks like the `docs` part of the url was being removed, so there's now one less `../` in the relative url.

* Fix other broken links on page & add `.md` extension to relative links
as suggested by @TkDodo
2025-04-29 11:18:25 +02:00
Dominik Dorfmeister
a2a39c92f1
docs: fix typo 2025-04-25 14:35:41 +02:00
Dominik Dorfmeister
c987abcafe
docs: Update streamedQuery.md 2025-04-25 10:37:57 +02:00
MINSEONG KIM
7cb634b6b3
docs: typo (#8932) 2025-04-02 08:46:03 +02:00
Dominik Dorfmeister
4d67c1cfa3
feat(core): streamedQuery (#8814)
* feat: streamedQuery

* feat: streaming example

* chore: move

* chore: fix lock file

* docs: streamedQuery
2025-03-18 12:09:51 +01:00
Kristian
24064358c0
docs(react-query): fix broken links in QueryClient docs (#8748)
Co-authored-by: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com>
2025-03-07 14:31:26 +11:00
Matt Tingen
3124193c08
docs: describe query default changes in v5 (#8488)
Fixes #8485
2025-01-03 15:21:03 +01:00
Dominik Dorfmeister
76900b8f27
docs: remove confusing sentence (#8411) 2024-12-07 09:07:34 +01:00
Dominik Dorfmeister
edec4a64c0
feat(core): ensureInfiniteQueryData (#8048)
* feat(core): ensureInfiniteQueryData

* docs: ensureInfiniteQueryData

* feat(types): make sure we can't pass infiniteQueryOptions to non-infinite query functions like fetchQuery
2024-09-12 11:53:29 +02:00
Chamath Palihawadana
8ecf0f7822
docs(query-client): broken hydration link (#7718) 2024-07-11 11:34:19 +02:00
Dominik Dorfmeister
721730a6a9
feat: allow to dehydrate and restore promises (#7481)
* feat: allow to dehydrate and restore promises

* fix: retries with initialPromise, but without queryFn

* fix: retries for infinite queries

this could use some reconciliation

* refactor: streamline the way we get the queryFn between Query and InfiniteQuery

* fix: only dehydrate query.promise for pending queries

* feat: allow setting hydration and dehydration defaultOptions on the QueryClient

* test: global defaultOptions for hydrate / dehydrate

* tests: hydration of promises

* feat: next15 integration test

* docs: app directory prefetching example

* docs: global hydrate and dehydrate options

* feat: use streaming

* docs: prefetching

* test: useQuery with initialPromise

* fix: do not leak server errors to the client

* docs: typo

* fix: ignore next in sherif

because we test against multiple versions of next

* test: await promise before clearing client to avoid error

* feat: always respect the `promise` passed to hydrate, even if we already have a cached entry.

* Update docs/framework/react/guides/advanced-ssr.md

Co-authored-by: Fredrik Höglund <fredrik.hoglund@gmail.com>

* Update docs/framework/react/guides/advanced-ssr.md

Co-authored-by: Fredrik Höglund <fredrik.hoglund@gmail.com>

* chore: remove leftover 'use client'

* oops

* docs: better text

* chore: better error messages

* update note

* chore: fix lock file

---------

Co-authored-by: Fredrik Höglund <fredrik.hoglund@gmail.com>
2024-05-27 20:13:24 +02:00
fuko
8fa82653dd
docs: fix broken internal links in the query docs (#7247)
* wip - 1

* Fix more links

* Fix one more link

* Another one

* Update a link

* Fix the broken links in the Angular docs

* Fix the broken links in the Vue docs

* Fix the Svelte links in the docs

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2024-04-22 10:38:13 +02:00
Andre de Waard
e34bf4d03a
feat(ensureQueryData): add 'revalidateIfStale' option (#6996)
* feat(fetchQuery): add 'prefetchWhenStale' option

* Revert "feat(fetchQuery): add 'prefetchWhenStale' option"

This reverts commit 76cd6a7719.

* fetch(ensureQueryData): Add revalidateIfStale option

* fetch(ensureQueryData): Add revalidateIfStale option

* fetch(ensureQueryData): Add revalidateIfStale option

* test(ensureQueryClient) implemented test for new option 'revalidateIfStale'

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

* feat(fetchQuery): formatted file

* Update docs/reference/QueryClient.md

* chore: prettier

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2024-03-13 13:15:28 +01:00
Dominik Dorfmeister
ee4fa28840
docs: remove outdated section
closes #6824
2024-02-18 09:24:55 +01:00
Dominik Dorfmeister
61f4d74788
refactor(types): make queryKey required on ObserverOptions (#6879)
* refactor(types): make queryKey required on ObserverOptions

we cannot create an observer without a key, because an observer, per definition, watches a certain query by its key

* test: observers need a key

* chore: remove a branch that can't exist

we can't have an observer without a queryKey

* fix: when comparing with shallowEqualObjects, the currentResult must come first

because it doesn't detect length changes

* test: we get another event

* types: you can't set queryKey as default

* a test for undefined queryKey makes no sense

* fix: more type issues

* types: queryKey is also not required for defaultOptions in solid

* fix(core): shallowEqualObjects should return false for objects with different lengths

as we use it for options, and the length of options can change
2024-02-17 19:32:06 +01:00
Lachlan Collins
5a5b61b19b
docs: Fix relative link depth (#6778) 2024-01-26 19:53:40 +11:00
Lachlan Collins
86b8a1df6b
docs: Fix broken links, share reference docs (#6777) 2024-01-26 19:30:21 +11:00
Damian Osipiuk
198017b75d
docs: align routing with framework switcher (#4608)
* docs: align routing with framework switcher

Co-authored-by: Aryan Deora <adeora@iu.edu>

* docs: remove angular from docs config

* docs: add doc ref redirect example

Co-authored-by: Aryan Deora <adeora@iu.edu>
2022-12-16 10:25:43 +01:00
Allan López
f364fbbf49
docs(useInfiniteQuery): add isRefetching to returned properties docs (#4567) 2022-11-29 21:13:57 +01:00
Michal Tecza
e5786715c6
docs: fix the example for queryClient.ensureQueryData (#4572) 2022-11-29 20:29:39 +01:00
Michal Tecza
1e0745a6cc
feat: queryClient.ensureQueryData (#4544)
* feat: queryClient.ensureQueryData

* style: apply prettier

* refactor: make interface of `queryClient.ensureQueryData` similar to `queryClient.fetchData`

* docs: update docs of `ensureQueryData`

* style: apply prettier formatting

* docs: adjust options description

* refactor: improve types of ensureQueryData overloads

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

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2022-11-26 17:33:23 +01:00
Michal Tecza
6b9549f07c
docs: fix docs for queryClient.getQueryData (#4545) 2022-11-26 09:53:50 +01:00
Dominik Dorfmeister
1f441b1427
docs: immutability 2022-11-08 12:07:27 +01:00
Michal Tecza
c45c1bfc4c
fix(query-core): make isRefetching false when fetching next/previous page in an infinite query (#4465)
* fix: make isRefetching false when fetching next/previous page in an infinite query

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

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

* Apply suggestions from code review

* prettier

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2022-11-06 16:40:33 +01:00
Suleman Tariq
a7e067c290
docs: Update useQuery.md (#4441)
Add missing bracket for object destructuring inside useQuery hook.
2022-11-03 15:54:07 +01:00
Dominik Dorfmeister
c376158afa
feat: add deprecation warnings
* feat: deprecate isDataEqual

* feat: deprecate contextSharing

* feat: deprecate custom loggers

* test: fix ssr-hydration tests

we need to compare against actual console.log here (and not our own logger), because react hydration mismatches are also logged to the console if they exist. This has surfaced another issue because of how we import react for react17/18 differential testing.

* fix: remove useEffect

that would wind up empty in production, and since this is just during development mode, we can just log during render

* test: adapt tests

we can remove most of these in v5

* chore: fix console.mock declaration

* feat: deprecate placeholder data function

* chore: scope test execution to src directories

if we do `pnpm test` locally, it first does typechecking, which produces output in `build` (including test files). Those will then be tested as well and the svelte tests fail with that.

* test: fix vue query test

* un-deprecate placeholderData function

we might still need it after all - to be discussed

* un-deprecate placeholderData function

* fix auto import
2022-11-01 11:55:49 +01:00
Dominik Dorfmeister
e152ea5c21
docs: prefer object syntax in docs (#4409)
* docs: useQuery to object syntax

* docs: invalidateQueries to object syntax

* docs: useMutation to object syntax

* docs: infinite query and other references to object syntax
2022-11-01 11:54:49 +01:00
Jonas Kugelmann
07c96311a5
feat(query-core): Expose retry error as failureReason (#4315)
* feat(query-core): Expose retry error as `failureReason`

* feat: Add `failureReason` to mutation as well

* fix: mutation `failureCount` not being reset to `0` on success

* chore: Add tests for mutation loading state reset

* fix: linting + tests
2022-10-22 11:58:27 +02:00