Commit b84681f
authored
v4 alpha (#3060)
* feat(hydration): remove hydration package (#2936)
* V4: streamline cancel refetch (#2937)
* feat: streamline cancelRefetch
the following functions now default to true for cancelRefetch:
- refetchQueries (+invalidateQueries, + resetQueries)
- query.refetch
- fetchNextPage (unchanged)
- fetchPreviousPage (unchanged)
* feat: streamline cancelRefetch
make sure that refetchOnReconnect and refetchOnWindowFocus do not cancel already running requests
* feat: streamline cancelRefetch
update tests
refetch and invalidate now both cancel previous queries, which is intended, so we get more calls to the queryFn in these cases
* feat: streamline cancelRefetch
add more tests for cancelRefetch behavior
* feat: streamline cancelRefetch
update docs and migration guide
* feat: streamline cancelRefetch
simplify conditions by moving the ?? true default down to fetch on observer level; all 3 callers (fetchNextPage, fetchPreviousPage and refetch) just pass their options down and adhere to this default; refetch also only has 3 callers:
- refetch from useQuery, where we want the default
- onOnline and onFocus, where we now explicitly pass false to keep the previous behavior
and add more tests
* feat: streamline cancelRefetch
we always call this.fetch() with options, so we can just as well make the mandatory
also, streamline signatures by destructing values that can't be forwarded (and use empty object as default value) in options and just spread the rest
* feat: streamline cancelRefetch
fix types for refetch
it was accidentally made too wide and allowed all refetchFilters, like `predicate`; but with `refetch` on an obserserver, there is nothing to filter for, except the page, so that is what we need to accept via `RefetchPageFilters`
* feat: streamline cancelRefetch
refetch never took a queryKey as param - it is always bound to the observer
* feat: better query filters (#2938)
* fix: rename react directory to reactjs (#2884)
* fix: rename react directory to reactjs
the directory being named "react" causes an error with the moduleDirectories option from jest
* fix: update package.json files to match the updated reactjs directory name
* fix: change react test utils imports to match new directory name
* docs(v4): add renamed reactjs details to migration guide
Co-authored-by: Eddy Vinck <[email protected]>
* feat: mutation cache duration (#2963)
* feat: mutation cachetime
stramline queryCache / mutationCache events by combining them into notifiable.ts
* feat: mutation cachetime
removable
* feat: mutation cachetime
add gc to mutations
* feat: mutation cachetime
streamline event types between queries and mutations
* feat: mutation cachetime
tests, and I forgot to implement optionalRemove, so make it abstract
* feat: mutation cachetime
replicate gc behavior from #2950 and add more tests
* feat: mutation cachetime
get test coverage back to 100%
* feat: mutation cachetime
docs
* feat: mutation cachetime
try to make tests more resilient
* feat: mutation cachetime
fix imports after merge conflict
* refactor(persistQueryClient): Make persistQueryClient stable (#2961)
* 🚚 Remove experimental from persist-query-client
* 🚚 Rename persistor -> persister
* ✏️ Fix Persistor -> Persister in imports
* 🚚 Update name in rollup config
* 🚚 Move createAsyncStoragePersister and createWebStoragePersister to stable version and rename persistor -> persister
* 📝 Update documentation
* 📝 Add migrating to v4 docs
* Apply suggestions from code review
Co-authored-by: Dominik Dorfmeister <[email protected]>
* 2964 changes to on success callback (#2969)
* feat(useQuery): onSuccess callback
do not call onSuccess if update was done manually from setQueryData
* feat(useQuery): onSuccess callback
test that onSuccess is not called when setQueryData is used
* feat(useQuery): onSuccess callback
docs changes
* feat(useQuery): onSuccess callback
options spread is wrong - `updatedAt` is actually `dataUpdatedAt`. Oddly we didn't have a test, so I added one
* 2919 query key array (#2988)
* feat: query key array
remove code that internally ensures that we get an Array, because it is now the expected interface, ensured by TypeScript
* feat: query key array
update tests to the new syntax
* feat: query key array
fix assertions, because there is no array wrapping happening internally anymore. The key you receive from the context is exactly the key you passed in
* feat: query key array
this test doesn't make much sense anymore
* feat: query key array
wrapping in an extra array doesn't yield the same results anymore since v4 because keys need to be an array
* feat: query key array
make docs adhere to new array key syntax
* feat: query key array
migration docs
* feat(QueryObserver): track queries as default (#2987)
* feat(Query Options): remove notifyOnChangePropsExclusion
- remove related code from queryObserver
- remove type def
- remove related tests
* docs(Query Options): update notifyOnChangePropsExclusion sections
- remove from api references
- add to v4 migration guide
* feat(QueryObserver): "tracked" as default behavior
- remove "tracked" completely if notifyOnChangeProps is not defined, behave as v3 "tracked"
- add `notifyOnChangeProps: 'all' to opt out of the smart tracking
TODO: Now that default behavior has changed, work out the failed tests. Which parts to change for current ones and possibly write new ones.
* test(useQuery): adjust tests to pass for notifyOnChangeProps udpate
* test(useInfiniteQuery): adjust tests to pass for notifyOnChangeProps udpate
* test(QueryResetErrorBoundary): adjust tests to pass for notifyOnChangeProps udpate
* refactor(QueryObserver): use nullish coalescing operator
much cleaner than the negated if I started with
* test(QueryResetErrorBoundary): remove "tracked" from test
* revert: test(QueryResetErrorBoundary): adjust tests to pass for notifyOnChaneProps udpate
This reverts commit a34b472.
The changes are not necessary after PR #2993 fix.
* refactor(QueryObserver): combine prop checks
* docs(notifyOnChangeProps): update docs to reflect new api
* refactor: Remove deprecated promise cancel (#2996)
* 🔥 Remove the cancel method on promise for cancelling promise
* ✅ Fix query client tests
* ✅ Update query and useQuery tests
* ✅ Update use infinite query tests
* 📝 Update migartion guide
* 🐛 Fix linking in documentation
* 📝 Fix grammatical errors in docs
Co-authored-by: Dominik Dorfmeister <[email protected]>
* :refactor: Use abortSignal for query cancellation in InfiniteQueryBehavior
* 🚨 Fix lint errors
* ♻️ Move define signal property to a separate function
Co-authored-by: Dominik Dorfmeister <[email protected]>
* remove test that doesn't make sense anymore - we don't allow different falsy query keys now
* 2927 offline queries (#3006)
* feat(useQuery): offline queries
remove defaultQueryObserverOptions because it is the same as defaultQueryOptions and we can just use that
* feat(useQuery): offline queries
setup dependent default values, to make it easier to work with them
* feat(useQuery): offline queries
basic changes to retryer:
- pause the query before fetching depending upon networkMode
- pause retries depending upon networkRetry
* feat(useQuery): offline queries
move networkRetry and networkMode defaults to the retryer creation, because we need the same for mutations
* feat(useQuery): offline queries
decouple focus and online manager: we're now informing caches of a focus when we're focussed, and about an online event if we come online; if the retryer continues, it can then decide to not fetch depending on our networkMode
* feat(useQuery): offline queries
expose isPaused on the queryResult and make sure isFetching is false when we are paused
* feat(useQuery): offline queries
knowing if we can fetch depends on if we are paused or not, as other conditions should apply
also, rename options (not sure if that will stick though)
* feat(useQuery): offline queries
adjust existing tests for isPaused being exposed
* feat(useQuery): offline queries
fix existing test by setting options to emulate the previous behaviour, otherwise, with `mockNavigatorOnline` being set to false right from the start, the mutation would never fire off
* feat(useQuery): offline queries
adapt onOnline, onFocus tests to new behavior: they are now decoupled, and onOnline is always called even when not focused and vice versa. The retryer should make sure to not continue fetching if necessary
* feat(useQuery): offline queries
first test for networkMode
* feat(useQuery): offline queries
isFetching and isPaused are now derived and stored together in a fetchingState enum (idle, fetching, paused)
* feat(useQuery): offline queries
better networkMode api: online, always, offlineFirst (basically always but with paused retries)
* feat(useQuery): offline queries
more tests for networkMode: online
* feat(useQuery): offline queries
more tests for networkMode: online
* feat(useQuery): offline queries
tests for networkMode: always
* feat(useQuery): offline queries
fix tests that were influencing each other by using proper jest mocks for online and visibility state
* add paused queries to the devtools.tsx
* feat(useQuery): offline queries
never stop pausing when continueFn is called. Initially, I only had this guard for when it's called from the outside, e.g. for onWindowFocus while still being offline, but we need this always because otherwise query cancellation can potentially continue a paused query
* feat(useQuery): offline queries
okay, pausing multiple times was a bad idea, continueFn() will be called eventually anyways
* feat(useQuery): offline queries
attempt at offline toggle button
* feat(useQuery): offline queries
different icons, padding, color
* feat(useQuery): offline queries
i messed up the icon order
* feat(useQuery): offline queries
guard against illegal state transitions: paused queries can unmount or get cancelled, in which case we shouldn't continue them, even if we dispatch the continue event
* feat(useQuery): offline queries
fix devtools tests, account for paused queries
* Revert "feat(useQuery): offline queries"
This reverts commit a647f64.
* feat(useQuery): offline queries
keep the do-not-start logic out of the run function, and thus out of promiseOrValue. if the promise has already been resolved in the meantime, e.g. because of a `cancel`, the run method will just do nothing, while the previous logic would've started to fetch
* feat(useQuery): offline queries
show inactive as higher priority than paused
* feat(useQuery): offline queries
make sure that optimistic results don't show an intermediate fetching state, but go opmistically to paused instead
* feat(useQuery): offline queries
real result needs to match optimistic result
* feat(useQuery): offline queries
stupid mistake
* feat(useQuery): offline queries
keep status color and status label in sync
* feat(useQuery): offline queries
make networkMode param mandatory for canFetch (and default to online internally) so that we can't screw that up again
* feat(useQuery): offline queries
make sure test "finishes" to avoid prints to the console if another test goes online again
* feat(useQuery): offline queries
move cancel function to the top, as it's no longer dependent on the promise since the `.cancel` function is gone; all we need is to abort the signal and reject the promise of the retryer
* feat(useQuery): offline queries
inline canContinue, because it's now only called if the query is in paused state anyways
* feat(useQuery): offline queries
avoid the impossible state by not calling config.onContinue for already resolved queries, as that would put them right into fetching state again, without actually fetching
* feat(useQuery): offline queries
let resolved querie continue, but don't put them in fetching state
* feat(useQuery): offline queries
fix merge conflict and invert condition because no-negated-condition
* feat(useQuery): offline queries
add test for abort signal consumed - different results expected for node < 15 where we don't have AbortController, thus can't consume the signal
* feat(useQuery): offline queries
online queries should not fetch if paused and we go online when cancelled and no refetchOnReconnect
* feat(useQuery): offline queries
gc test
* feat(useQuery): offline queries
offlineFirst test
* feat(useQuery): offline queries
mock useMediaQuery to get rid of unnecessary check in devtools - if window is defined, `matchMedia` is also defined
* feat(useQuery): offline queries
use a higher retryDelay to make test more stable, otherwise, it might start retrying before we "go offline"
* feat(useQuery): offline queries
improve devtools test: check if onClick props are being called
* feat(useQuery): offline queries
add devtools test for offline mock
* feat(useQuery): offline queries
offline mutations test
* feat(useQuery): offline queries
network mode docs (unfinished)
* feat(useQuery): offline queries
network mode docs
* feat(useQuery): offline queries
fix merge conflicts
* refactor(queryClient): remove undocumented methods
* fix: offline mutations fixes (#3051)
* feat: offline mutations
move reducer into Mutation class to avoid passing state (and options) around
* feat: offline mutations
optimistically set paused state depending on if we can fetch or not to avoid an intermediate state where we are loading but not paused
* examples: fix query keys in basic examples
because we need those for preview builds
* fix(useMutation): make sure cacheCallbacks are always called
even if the useMutation component unmounts and we have a cacheTime of 0; the fix was cherry-picked from the react-18 branch, where we also introduced this behavior
* Feature/cachetime zero (#3054)
* refactor: cacheTime-zero
remove special handling for cacheTime: 0 and schedule a normal garbage collection for those queries. They will be eligible for gc after a setTimeout(0), but then they will only be optionally removed. This makes sure that paused queries are NOT gc'ed
* refactor: cacheTime-zero
remove special test "about online queries with cacheTime:0 should not fetch if paused and then unmounted". paused queries will now be kept until they continue, just like with every other query, unless query cancellation or abort signal was involved
* refactor: cacheTime-zero
adapt "remounting" test: if the same query with cacheTime 0 unmounts and remounts in the same cycle, the query will now be picked up and will not go to loading state again. I think this is okay
* refactor: cacheTime-zero
re-add instant query removal after fetching, because fetching via `queryClient.fetchQuery` will not remove the query otherwise, because the normal gc-mechanism now checks for `hadObservers` due to a suspense issue :/
* refactor: cacheTime-zero
weird edge case: the previous logic was instantly removing the query _while_ it was still fetching, which is something we likely don't want. The data will stay in the currentQuery of the observer if the observer unsubscribes but still exists, and a new subscription will pick it up, unless the query was explicitly cancelled or the abort signal was consumed.
* refactor: cacheTime-zero
we need to wait a tick because even cacheTime 0 now waits at least a setTimeout(0) to be eligible for gc
* refactor: cacheTime-zero
schedule a new garbage collection after each new fetch; this won't do anything when you still have observers, but it fixes an edge case where prefetching took longer than the cacheTime, in which case the query was again never removed
test needed adaption because we don't instantly remove, but deferred by a tick
* refactor: cacheTime-zero
stabilize test
* refactor: cacheTime-zero
apply a different suspense "workaround": do not garbage collect when fetching optimistically (done only by suspense) - gc will kick in once an observer subscribes; this will make sure we can still gc other fetches that don't have an observer consistently, like prefetching when the fetch takes longer than the gc time (which was leaking with the old workaround)
* refactor: cacheTime-zero
remove leftover
* refactor: cacheTime-zero
since every fetch triggers a new gc cycle, we don't need to do this in a loop anymore
also, reset isFetchingOptimistic after every fetch
* add publishing capabilities for alpha branch
* fix(queryFilters): fetchStatus to queryFilters (#3061)
Co-authored-by: Eddy <[email protected]>
Co-authored-by: Eddy Vinck <[email protected]>
Co-authored-by: Prateek Surana <[email protected]>
Co-authored-by: Rene Dellefont <[email protected]>
BREAKING CHANGE: new query filters, query key must be an array1 parent ebf1e68 commit b84681f
File tree
127 files changed
+3126
-1409
lines changed- .github/workflows
- createAsyncStoragePersister
- createAsyncStoragePersistor-experimental
- createWebStoragePersister
- createWebStoragePersistor-experimental
- docs/src
- manifests
- pages
- guides
- plugins
- reference
- examples
- basic-typescript/src
- basic/src
- hydration
- persistQueryClient-experimental
- persistQueryClient
- reactjs
- react
- src
- broadcastQueryClient-experimental
- core
- tests
- createAsyncStoragePersister
- createWebStoragePersister
- tests
- devtools
- tests
- hydration
- persistQueryClient
- reactjs
- tests
- react
- ts3.8
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
127 files changed
+3126
-1409
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
| |||
204 | 209 | | |
205 | 210 | | |
206 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
207 | 217 | | |
208 | 218 | | |
209 | 219 | | |
| |||
314 | 324 | | |
315 | 325 | | |
316 | 326 | | |
317 | | - | |
| 327 | + | |
318 | 328 | | |
319 | 329 | | |
320 | 330 | | |
321 | 331 | | |
322 | | - | |
323 | | - | |
324 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
325 | 335 | | |
326 | 336 | | |
327 | | - | |
328 | | - | |
329 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
330 | 340 | | |
331 | 341 | | |
332 | 342 | | |
| |||
442 | 452 | | |
443 | 453 | | |
444 | 454 | | |
445 | | - | |
| 455 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
| 41 | + | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
0 commit comments