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

138 commits

Author SHA1 Message Date
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
Kenrick Beckett
8b899410c8
docs: Remove the variable assignment from example code (#7623)
* Remove the variable assignment from example code

* remove variable assignment in prefetch query docs

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2024-06-27 14:48:18 +02:00
John
31b9ab49af
feat(core): Add possibility to pass a callback to enabled. (#7566)
* 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>
2024-06-25 16:10:16 +02:00
Dominik Dorfmeister
fbfe9409ca
feat(react-query): usePrefetchQuery (#7582)
* 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>
2024-06-25 14:25:28 +02:00
Dominik Dorfmeister
96a743eec7
feat(query-core): staleTime as a function (#7541)
* feat: staleTime as a function

* test: staleTime as a function

* refactor: types

* docs: staleTime as function
2024-06-11 15:11:40 +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
Jason Gerbes
8ce6642d12
feat(query-core): improve useInfiniteQuery error handling (#7418)
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2024-05-12 16:12:33 +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
Dominik Dorfmeister
24f1d45cbd
feat: scoped mutations (#7312)
* 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
2024-04-22 08:39:11 +02:00
Anthony Gonzales
a9fa5f4e9b
docs: Remove references to React.FC (#7259)
React.FC was removed from the create-react-app template in
facebook/create-react-app#8177 and is no longer recommended.
2024-04-11 11:16:39 +02:00
Christopher Ehrlich
fca5e7df77
docs: correct useQuery status type (#7252) 2024-04-09 18:07:17 +02:00
Dominik Dorfmeister
e707c13ce3
docs: render optimizations (#7234)
* docs: render optimizations

* docs: further reading
2024-04-05 20:06:06 +02:00
Dominik Dorfmeister
3c31124ddb
feat(core): memoize result of combine (#7233)
* 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
2024-04-05 19:56:40 +02:00
Tanner Linsley
754640a3e5
docs: migrate docs to use path-based navigation instead of route-based (#7211)
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.
2024-04-02 16:46:31 -06:00
Gioele Vuaran
0123c8094d
docs: gcTime max value (#7190) 2024-04-02 17:15:08 +02:00
Lachlan Collins
aa9a789d36
docs: Fix formatting, run CI on docs changes (#7018) 2024-03-04 19:25:02 +11:00
LeeJaeSang
663afdc6ca
docs: fix-useQueries-syntax-error (#7017) 2024-03-04 07:43:41 +01:00
Niels Bosman
847a99696e
docs(react-query): fix typo in useMutation data attribute (#6921) 2024-02-17 22:51:58 +01:00
Dominik Dorfmeister
aad40787e4
fix(types): type structural sharing as unknown (#6888) 2024-02-13 13:46:31 +01:00
Jeong-Sik Yun
58b3de8680
doc: Change the onMutate optional description to capitalize. (#6773) 2024-01-27 14:05:42 +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
Lachlan Collins
0cdbd5a198
docs: Re-organise for new docs layout (#6763)
* docs: Re-organise for v2 docs layout

* Add $schema
2024-01-26 07:57:22 +11:00