* 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>
* Add possibility to pass a callback to enabled.
* Refactor into using the same pattern as resolving staletime, with the use of a resolveEnabled util function
* Update tests for enabled option as a callback
* update docs
* remove typo
* Update enabled type in docs
* remove duplicated test case
* Fix eslint errors
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: John Pettersson <john.pettersson@carnegie.se>
* feat: usePrefetchQuery
* refactor: switch to actual prefetching
* refactor: remove ensureInfiniteQueryData function
will do in a separate PR
* chore: add tests for usePrefetchQuery and usePrefetchInfiniteQuery (#7586)
* chore: add tests for usePrefetchQuery and usePrefetchInfiniteQuery
* chore: update tests to assert the alternative spy is not called
* chore: add some new tests
* chore: remove it.only whoops
* chore: call mockClear after fetching
* chore: improve waterfall test by asserting fallback calls instead of loading node query
* chore: improve code repetition
* chore: add some generics to helper functions
* usePrefetchQuery type tests and docs (#7592)
* chore: add type tests and docs
* chore: update hooks to use FetchQueryOptions and FetchInfiniteQueryOptions
* chore: update tests
* chore: update docs
* chore: remove .md extension from link
* chore: add unknown default value to TQueryFnData
* Apply suggestions from code review
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* Apply suggestions from code review
Co-authored-by: Fredrik Höglund <fredrik.hoglund@gmail.com>
* chore: fix types in tests
* chore: add new tests (#7614)
* chore: add new tests
* Apply suggestions from code review
---------
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
---------
Co-authored-by: Bruno Lopes <88719327+brunolopesr@users.noreply.github.com>
Co-authored-by: Fredrik Höglund <fredrik.hoglund@gmail.com>
* 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>
* 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>
* refactor: add scope to mutationCache internally
* refactor: remove unused defaultOptions on mutation
this private field is a leftover from v4
* feat: make sure to not run mutations if there is already one running in the scope of this mutation
* feat: make sure mutations in the same scope can run in serial
* fix: find a _lot_ better way to determine if a mutation can run
* test: widen test scenario to include scopes
* fix: there is a difference between starting and continuing
when starting, we need to check the networkMode differently than when continuing, because of how offlineFirst works (can start, but can't continue)
* refactor: switch to a scope object with `id`
* feat: dehydrate and hydrate mutation scope
* fix: initiate the mutationCache with a random number
since we use the mutationId to create the default scope, and the mutationId is merely incremented, we risk colliding scopes when hydrating mutations into an existing cache. That's because the mutationId itself is never dehydrated. When a mutation gets hydrated, it gets re-built, thus getting a new id. At this point, its id and the scope can differ. That per se isn't a problem. But if a mutation was dehydrated with scope:1, it would put into the same scope with another mutation from the new cache that might also have the scope:1.
To avoid that, we can initialize the mutationId with Date.now(). It will make sure (or at least very likely) that there is no collision
In the future, we should just be able to use `Crypto.randomUUID()` to generate a unique scope, but our promised compatibility doesn't allow for using this function
* test: hydration
* test: those tests actually fail because resumePausedMutations is still wrongly implemented
* fix: simplify and fix resumePausedMutations
we can fire off all mutations at the same time - only the first one in each scope will actually fire, the others have to stay paused until their time has come. mutation.continue handles this internally.
but, we get back all the retryer promises, so resumePausedMutations will wait until the whole chain is done
* test: more tests
* refactor: scopeFor doesn't use anything of the mutationCache class
* docs: scoped mutations
* feat(core): memoize result of combine
this PR makes sure to only re-run the combine function if the function itself changed referentially or any of the inputs changed
* docs: combine memoization
* Update docs/framework/react/reference/useQueries.md
TanStack Router uses path-based navigation instead of route-based navigation, so many of the relative documentation links will be invalid after migration. This fixes that.