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

5,002 commits

Author SHA1 Message Date
Janne Vuoti
c51498a935
fix(useQueries): search for unused observers if keepPreviousData (#2680) (#2866) v3.33.6 2021-11-26 21:06:00 +01:00
Alec Flett
c6906b3c4d
fix(useQueries): add useMemo to useQueries to keep result stable (#2992) v3.33.5 2021-11-24 20:07:44 +01:00
Timo Dörr
f18881d27b
docs: add pitfalls section for window focus refetching (#3018) 2021-11-24 08:48:24 +01:00
Tomer
911477422f
docs(query-keys guide): change "And" to "An" (#3010) 2021-11-23 12:03:21 +01:00
Dominik Dorfmeister
0aafb42fcc
fix(query): make sure prefetched queries can be garbage collected (#3007) v3.33.4 2021-11-22 17:40:11 +01:00
Dominik Dorfmeister
27e72de267
fix(useQuery): cleanup queries even if they have been fetching (#2950) v3.33.3
* fix(useQuery): cleanup queries even if they have been fetching

* fix(useQuery): cleanup queries even if they have been fetching

do not re-schedule garbage collection if a query is fetching and we never had any observers subscribed; this is necessary to make suspense work, because with suspense, we always throw before we subscribe, so the garbage collection would prematurely remove the query, resulting in an infinite loop

* fix(useQuery): cleanup queries even if they have been fetching

only schedule garbage collection when the last observer unsubscribes rather than in the constructor

this works around the suspense issue because we only add observers after we've loaded as we throw before that.
2021-11-22 14:45:21 +01:00
allcontributors[bot]
ebd22b203a
docs: add babycourageous as a contributor for code, doc (#2995)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-11-20 17:42:36 +01:00
Dominik Dorfmeister
58dc1ce626
fix(useQuery): fix tracked queries and error boundaries (#2993) v3.33.2
if you useErrorBoundary, you're likely not observing the error, because you're not using the returned error field - the ErrorBoundary handles the error for you. So when the actual error then happens, we don't inform the observer about it, because we're only informing them if a prop has changed that they are interested in, resulting in the error boundary never being shown.

The solution would be to always track the error property if you've set useErrorBoundary
2021-11-20 08:57:36 +01:00
allcontributors[bot]
c2727c118f
docs: add prateek3255 as a contributor for code (#2970)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-11-18 18:08:49 +01:00
allcontributors[bot]
fe1e9050ed
docs: add EddyVinck as a contributor for code (#2967)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-11-17 21:13:39 +01:00
allcontributors[bot]
27143438ce
docs: add KATT as a contributor for code (#2965)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-11-17 19:53:18 +01:00
Dominik Dorfmeister
7948e7a291
chore: remove trailing comma in all-contributorsrc 2021-11-17 19:33:16 +01:00
Andrew Nguyen
16131c30f8
fix(devtools): improve devtools a11y (#2947) v3.33.1
* fix(devtools): improve devtools container a11y

default element changes to aside from footer because aside
represents a portion of a document whose content is only indirectly
related to the document's main content.
aria-label is also added to replace the text "generic" in a11y tree.

* fix(devtools): add aria to devtools toggle button

aria-expanded indicates open/closed of the menu
aria-haspopup indicates this is a menu button
aria-controls to link to the menu, also added aria-label on the menu to
label it.

Read more: https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-links.html

* fix(devtools): menuitem are visible in a11y tree in closed devtools

This is because the element is just hidden visually, but is still inside
the DOM. The added conditional display only affects the inner container,
which means the animation of opening/closing is reserved.
2021-11-17 18:16:16 +01:00
Daniel Bartsch
52854795b6
feat(useMutation): meta for mutations (#2906) v3.33.0 2021-11-17 12:30:39 +01:00
Nika Sepiskveradze
62e12e563e
docs(reference): fixed right sidebar width issue (#2952) 2021-11-17 12:29:06 +01:00
Arnaud
1dc4186756
docs(cancel): add graphql-request example (#2948) 2021-11-15 14:09:00 +01:00
Tanner Linsley
c1ae82ba18
Update README.md 2021-11-12 14:18:11 -07:00
Dominik Dorfmeister
2c36b6d9e9
fix(useQuery): don't throw error if errorBoundary has just been reset (#2935) v3.32.3
the fix for disabled queries was wrong, because disabled queries still need to throw if they are fetching due to some other means, like `refetch`. However, if a query has just been reset, we want to skip throwing for one render cycle. The useEffect that clears the reset will then make sure that further errors will be thrown
2021-11-12 22:11:12 +01:00
Dominik Dorfmeister
d3d7fc4451
fix(useQuery): make sure that disabled queries in error state don't throw (#2933) v3.32.2 2021-11-12 14:34:08 +01:00
Dominik Dorfmeister
57f47e13e1
docs: improve cancellation docs (#2932) 2021-11-12 13:19:37 +01:00
Bernhard Wittmann
35346218bc
docs(optimistic-updates): ease wording in introduction (#2908) 2021-11-11 08:58:20 +01:00
Emmanouil Zoumpoulakis
8065a7e8ed
docs: Typo fixes in Markdown files (#2910) 2021-11-10 20:43:07 +01:00
Arnaud
c118513e83
test(core): 100% code coverage (#2904)
* refactor(logger): assume that console is always defined

* test(utils): isPlainObject: should return `false` if the object has a modified prototype

* test(utils): scheduleMicrotask should throw an exception if the callback throw an error
2021-11-09 11:12:57 +01:00
Louis Law
c917ff7210
chore: add missing eslint-config-prettier for example, (#2898) 2021-11-08 17:25:01 +01:00
Arnaud
c989bde9e1
test(core): improve code coverage (#2876)
* test(InfiniteQueryObserver): should error if queryFn not defined

* test(InfiniteQueryObserver):  should not refetch the first page if refetch another page

* fix(logger): logger is always defined with the console

* test(InfiniteQueryBehavior): move new tests to InfiniteQueryBehavior

* test(QueryCache): add and remove tests

* test(QueryCache): add find with filters.exact defined

fix test.only on previous commit too.

* test(QueryCache): return all queries when no filters are set

fix: comparison in find(); filters object is always defined but could be empty.

* test(mutationObserver): add onUnsubscribe and notify tests

notify: there is no use case in the lib with listeners set to false.

* test(queriesObserver): should not destroy the observer if there is still a subscription

* test(queriesObserver): onUpdate should not update the result for an unknown observer

No onUpdate use case has been found with a possible unknown observer.

* test(queryObserver): the retrier should not throw an error when reject if the retrier is already resolved

* test(InfiniteQueryBehavior): add signal support

* test(hydration): dehydrateQueries false, mutation state pause, hydratedState empty

* test(focusManager): add full coverage tests

* test(query): should set default options

* test(query): should refetch the observer when online method is called

* test(query: should not add an existing observer

* test(query): should not try to remove an observer that does not exist

* test(query): should not dispatch on invalidate if already invalidated

* test(query): reducer should return the state for an unknown action type

Typescript made this case not possible.

* test(query): fetch should not dispatch fetch if meta has not changed

* test(queryClient): setQueryData should use prev data if isDataEqual fct is true

* test(queryClient): setQueryData should set the new data without comparison if structuralSharing is set to false

move related tests into 'setQueryData' test suite

* test(query): fetch should not set the signal  if AbortController is undefined

* test(query): fetch should throw an error if the queryFn is not defined

* test(query): fetch should dispatch fetch if is fetching and current promise is undefined

* test(query): constructor should call initialDataUpdatedAt if defined as a function

* test(queryObserver): should throw an error if enabled option type is not valid

* test(queryObserver): getCurrentQuery should return the current query

* test(queryObserver): should throw an error if throwOnError option is true

* test(queryObserver): should not refetch in background if refetchIntervalInBackground is false

* test(queryObserver): should not use replaceEqualDeep for select value when structuralSharing option is true

* test(queryObserver): add placeholderdata related tests

* fix(queryObserver): shouldNotifyListeners: remove useless condition

updateResult function already check the result with shallowEqualObjects

* test(queryObserver): updateResult should not notify cache listeners if cache option is false

* test(queryObserver): add stale timeout notify test

* test(mutation): setState should update the mutation state

setState is not used in the lib, need to force the usage in the test

* test(mutation): addObserver should not add an existing observer

No use case found, need to use the private method for the test.

* Revert "test(mutation): addObserver should not add an existing observer"

This reverts commit 3643be9518.

* test(mutation): addObserver should not add an existing observer

* test(mutation): executeMutation should throw an error if no mutationFn found

* test(mutation): cancel mutation should not call mutationFn if the current retrier is undefined

Force retryer to undefined because no use case has been found.

* Revert "fix(logger): logger is always defined with the console"

This reverts commit dd64fda076.

* test(mutation): reducer should return the state for an unknown action type

* test(onlineManager): isOnline: add navigator related tests

* test(onlineManager): setEventListener should use online boolean arg

* test(onlineManager): add setEventListener tests

* test(notifyManager): add notifyFn and batchNotifyFn tests

Add a notifyManagerTest singleton because jest.setup.js override notifyFn value.

* test(queryClient): add focusManager and onlineManager related test

* test(queryClient): cancelQueries should not revert if revert is false

* test(queryClient): refetchQueries should throw if throwOnError is true

* test(queryClient): add cancelMutations test

* test(queryClient): should get defaultOptions

* test(queryClient): should update existing query defaults

* test(queryClient): setMutationDefaults should update existing mutation defaults

* test(utils): parseMutationArgs should return mutation options

* test(utils): matchMutation should return false if mutationKey options is undefined

* test(utils): isPlainObject add tests

* test(core): use @ts-expect-error instead of @ts-ignore when possible

* test(core): export NotifyManager for testing purposes

* test(queryObserver): fix test comment
2021-11-07 13:01:37 +01:00
Arnaud
f03396f217
docs(queryCache): fix subscribe callback arg: event instead of query (#2897) 2021-11-07 12:36:38 +01:00
Martin Brodziansky
9edb305f45
fix(types): Export the Mutation type and change default TVariables from void to unknown (#2892) v3.32.1 2021-11-06 22:43:43 +01:00
New Future
b52b2779b3
feat(persistQueryClient): try to clean the old persistented data when storage full (#2851) v3.32.0 2021-11-06 17:52:40 +01:00
Emmanouil Zoumpoulakis
80f236d8c7
fix(devtools): Fix progressively smaller font size for Explorer (#2886)
Fix progressively smaller font size for Explorer entries in devtools
Set Entry font-size to 1em, because it is indented multiple time within each other.
This causes the font to get smaller and smaller as `em` is relative to the parent font size.
2021-11-06 17:50:59 +01:00
Prateek Surana
bfef84c066
chore: Add code coverage report (#2894) 2021-11-06 15:53:11 +01:00
Sam Cook
f348673dce
docs: Add note on AbortSignal version availability (#2887)
Explained that this new AbortSignal feature was introduced at 3.30.0 and that users need to either upgrade (recommended) or use the old cancel function.
2021-11-06 07:34:01 +01:00
Minh
c4fa60eb4d
docs: Minor typo (#2865) 2021-11-01 21:43:55 +01:00
Ben Grynhaus
8013d4a768
feat(persistQueryClient): add optional functions to serialize and deserialize from Storage Persistors (#2864) v3.31.0 2021-10-31 21:00:39 +01:00
henribru
69a5d798fe
docs: Fix typo in query cancellation docs (#2863) 2021-10-30 21:30:12 +02:00
James Wyatt Cready-Pyle
e7a3207f74
feat(useQuery): Provide AbortSignal to queryFn (#2782) v3.30.0 2021-10-30 20:26:57 +02:00
Alex Johansson
f21d932142
fix(types): expose CancelOptions & SetDataOptions (#2855) v3.29.1 2021-10-29 21:17:37 +02:00
Niclas van Eyk
e3fb5668cc
docs: Fix typo (#2850) 2021-10-28 16:31:03 +02:00
Raphaël Huchet
f90455727c
docs: fix typo for placeholder data (#2848) 2021-10-28 14:31:42 +02:00
Dominik Dorfmeister
718903debf
chore: switch from size-limit to bundlewatch (#2845) 2021-10-27 21:55:12 +02:00
Jan Dh
765830c55a
chore: Setup bundle size report (#2837) 2021-10-27 18:05:21 +02:00
Arnaud
6ba663f25a
test(devtools): devtools sort queries test fails on Apple Silicon M1 pro (#2832) 2021-10-27 13:30:48 +02:00
Bennett Dams
1aaca282af
docs: Extend type description of useQuery's onSuccess (#2836) 2021-10-27 13:29:24 +02:00
Arnaud
020bb92d9c
test(react): improve code coverage (#2826) 2021-10-26 22:09:11 +02:00
dohwan joshua kim
51fb925c65
test(useQuery): refetchOnMount test name (#2830) 2021-10-26 21:58:25 +02:00
Luis Felipe Zaguini
4472baea1d
feat(useQuery): add meta field (#2818) v3.29.0 2021-10-26 21:28:38 +02:00
Tanner Linsley
4d762a4ffe
Update index.js 2021-10-26 09:04:56 -06:00
Maful Prayoga Arnandi
461e9887e1
docs(TypeScript): fix useQueries link (#2824) 2021-10-23 21:19:35 +02:00
Arty
2c1d74baf7
feat(useQueries): enable types in useQueries (#2634) v3.28.0 2021-10-23 16:12:00 +02:00
Arnaud
2771a15403
fix(useBaseQuery): set cacheTime to 1 in Suspense mode when cacheTime is set to 0 (#2821) 2021-10-23 16:11:16 +02:00
phatmann
05a8057e2b
docs: Note that calling setQueryData triggers onSuccess (#2808) 2021-10-19 08:11:52 +02:00