* Add persisterRestoreByKey
* Fix imports
* Add missing return statement
* Fix test
* docs
* Add extra test
* Merge into single restoreQueries function
* 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`.
* 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
* fix(persistQueryClientRestore): Do not swallow exceptions during in persistQueryClientRestore within `restoreClient` and `removeClient`
* fix: rethrow errors in removeClient within all branches
* fix: test for PersistQueryClientProvider in all consumers
* chore: implement PR feedback
* chore: mock console calls, so they do not end up in the console. This way we can also assert on the invocations
* chore: consoleWarn mocks to be restored after each test
* chore: remove tmp file commited accidentally
* chore: adjust docs and include new optional callback `onError`
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Updated several mentions of "React Query" to "TanStack Query".
Wrote "formerly known as" instead of using a not all that well known abbreviation to better support the multilingual audience.
* docs: Add Connect RPC to the list of community projects
Connect RPC has a native TanStack Query integration.
https://github.com/connectrpc/connect-query-es
* 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>
* fix(examples): Promise returned from invalidateQueries being ignored in optimistic-updates-cache example
* fix(examples): Promise returned from invalidateQueries is ignored in optimistic-updates-ui example
* fix(docs): Promise returned from invalidateQueries is ignored in optimistic-updates documentation
* Update docs/framework/react/guides/optimistic-updates.md
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* refactor(docs, examples): standardize queryClient.invalidateQueries syntax in all onSettled callbacks
* 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>
* 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 (./ -> ../)