From 357ec041a6fcc4a550f3df02c12ecc7bcdefbc05 Mon Sep 17 00:00:00 2001 From: Dominik Dorfmeister Date: Mon, 18 Jul 2022 20:08:12 +0200 Subject: [PATCH] v4 release (#3842) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * 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 https://github.com/tannerlinsley/react-query/pull/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) * :truck: Remove experimental from persist-query-client * :truck: Rename persistor -> persister * ✏️ Fix Persistor -> Persister in imports * :truck: Update name in rollup config * :truck: 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 * 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 a34b4720675dad5ee6ebde401639f328c0c83122. 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) * :fire: 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 * :bug: Fix linking in documentation * :pencil: Fix grammatical errors in docs Co-authored-by: Dominik Dorfmeister * :refactor: Use abortSignal for query cancellation in InfiniteQueryBehavior * 🚨 Fix lint errors * :recycle: Move define signal property to a separate function Co-authored-by: Dominik Dorfmeister * 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 a647f64a051ca4c02a872e7871b4b2ce49aeda2c. * 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 Co-authored-by: Eddy Vinck Co-authored-by: Prateek Surana Co-authored-by: Rene Dellefont BREAKING CHANGE: new query filters, query key must be an array * refactor(core): refactor internals from classes to a functions (#3066) * refactor(core): refactor retryer from a class to a function * refactor(core): refactor notifyManager from a class to a function * refactor(core): refactor notifyManager from a class to a function remove outdated comment * feat(useQueries): v4 api to take an object as input (#3071) * feat(useQueries): update API to use object syntax New v4 API - instead of taking an array of queries, `useQueries` now accepts an object with a `queries` key. The value of this key is an array of queries (this array is unchanged from v3). * test(useQueries): update tests for new API * docs(useQueries): update docs for v4 API * refactor(tests): adapt useInfiniteQuery test copied over from the react-18 branch, because that impl is less flaky * refactor(tests): adapt useInfiniteQuery test another one copied over from the react-18 branch, because that impl is less flaky * refactor: use a set for tracked props (#3085) * refactor: make listeners required because the only place where we pass no listener in is in tests * refactor: make notifyOnChangeProps a Set * chore: update tooling (#3086) * chore: update caniuselite * chore: remove const-enum babel plugin because we don't use const-enums anymore * chore: require ts 4.1 * chore: update rollup and plugins * chore: update typescript and ts-eslint * refactor: remove notifiable base class this abstraction costs more than the simple duplication, and we also have other notify functions which were not unified * fix(queryObserver): defer tracking of error prop when useErrorBoundary is on (#3087) adding "error" to the list of tracked properties will result in us _only_ tracking error if we want to track all properties implicitly by _not_ observing any properties (because we check for trackedProps.size). Moving the adding of "error" to _after_ the size check fixes this * docs: Update migrating-to-react-query-4.md (#3096) * refactor: remove logging in prod mode (#3103) to not log to the console per default; to access process.ENV, we need to enable node typings, which screws with setTimeout / setInterval, as typings are different for node and the browser; I tried to keep the changes to type-level only * refactor: remove cancel method as it no longer exists (#3142) * refactor: remove cancel method as it no longer exists it wasn't doing anything in that test * refactor: remove cancel method as it no longer exists use signal in playground example instead of cancel fn * refactor: remove unused query.setDefaultOptions * feat(persistQueryClient): improve persist controls (#3141) * feat(persistQueryClient): improve persist controls add restore/save/subscribe * docs: update persistQueryClient and hydration * docs: describe new persist features * docs(persistQueryClient): correct option defaults * feat(persistQueryClient): enable unsubscribe * docs(persistQueryClient): clarify restoration * docs(persistQueryClient): enable unsubscribe note * fix(persistQueryClient): subscribe awaits restore * docs: clarify caching behavior (#3221) The example contains at least one inacurate statement, > It will then cache the data using `'todos'` and `fetchTodos` as the unique identifiers for that cache. and could benefit from more precise language. * fix(core): do not refetch disabled queries (#3223) * fix(core): do not refetch disabled queries with refetchQueries or invalidateQueries + refetchType "inactive" disabled queries (=queries that have observers which are all enabled:false) are matched as "inactive"; this is okay when searching for them via findAll or for removeQueries, but the docs clearly state that refetchQueries / invalidateQueries do not refetch disabled queries, and that the only way to refetch them is via refetch returned from useQuery; this is important when using enabled to signal that some dependencies are not yet ready some tests needed to be adapted because we used disabled observer + refetchQueries a lot. The easiest way to emulate the observers we wanted here was mostly with initialData + staleTime, and to get a real inactive query, we just need to subscribe + unsubscribe immediately * fix(core): do not refetch disabled queries add tests for refetchQueries + disabled * fix(core): do not refetch disabled queries update test to make more sense - title said disabled queries, but we had no disabled query; test now does the opposite of what it did before, but that's what this PR does :) * refactor(mutation): remove mutation.cancel (#3225) as it wasn't really aborting the request - there is no AbortSignal for Mutations atm. * refactor(queryClient): add dev warning with queryDefaults (#3249) * refactor(QueryClient): add dev warning Warn when several query defaults match a given key. Could be error prone if the returned defaults are not the expected ones. The order of registration does matter. * test(QueryClient): warning with defaults options Highlight how query defaults registration order matters. * doc(QueryClient): add notes about query defaults In `getQueryDefaults`, the **first** matching default is returned. In `setQueryDefaults`, highlight how the registration order is important. * doc(QueryClient): fix link to documentation * test(QueryClient): better test * refactor(QueryClient): use internal logger * doc(QueryClient): fix markup * doc(QueryClient): remove extra entry * refacto(QueryClient): warn about several query defaults Warning must be displayed any time a conflict is detected, not just for dev build. The warning is aimed at helping developers *using* react-query, not those *developping* react-query. * Update src/core/queryClient.ts Remove useless optional chaining. Co-authored-by: Dominik Dorfmeister * feat(utils): add assert helper * refactor(QueryClient): add dev warning for mutation defaults * Revert "feat(utils): add assert helper" This reverts commit 05c3fe19cd3277bd99740564c2e771412b7cf109. * refactor(QueryClient): error when several defaults Review how the check for multiple defaults on a key is raised. Ensure it remains fast in release build. * refactor(QueryClient): inline code Co-authored-by: Guillaume Labat Co-authored-by: Dominik Dorfmeister * chore: fix silent merge conflicts * feat: Bail out if query data undefined (#3271) * Bail out if query data undefined * Fix failing test * docs: migration guide for undefined data * docs: update setQueryData reference * Update docs/src/pages/guides/migrating-to-react-query-4.md Co-authored-by: Louis Law Co-authored-by: Dominik Dorfmeister * chore: add a test to ensure that callback on .mutate are only called for the last observer * docs: Document compression use case for `createWebStoragePersister` (#3285) Add an example on how to `compress`/`decompress` data from local storage in case you need to cache large payloads. Context: https://github.com/tannerlinsley/react-query/pull/2864#issuecomment-1034604428 * refactor: inline / remove some functions for size improvements (#3289) * refactor: size inline reducers in query and mutation because they are only used from dispatch * refactor: remove default case in reducers actions are only produced by our own code, which is in TypeScript, so we'll get a type error if there is an action not handled. Unknown actions can't exist, as the tests show: we'd need a ts-expects-error to go this way * refactor: inline executeMutation because it's only used once * refactor: inline getObserver and updateObservers in useQueries because it's only used once * refactor: extract getDefaultState getDefaultState is a pure function, with no access to `this`, so we can extract it. This is in-line with what `mutation` is doing * refactor: remove getNextResult it was only used in tests, and it's also not documented * refactor: inline clearTimers because it's only used once * refactor: inline shouldNotifyListeners because it's only used once * refactor: inline resumePausedMutations * refactor: tests every stubbed queryFn needs a mock implementation to avoid console errors: Error: Query data cannot be undefined * refactor: do not log undefined query data warning to the console * feat: Version 4 codemods (#3195) * chore: add `jscodeshift` library to dev-dependencies We're planning to deliver codemods for the next release, so we will need this package to write codemods. * chore: add `@types/jscodeshift` library to dev-dependencies * chore: add an empty `jest` config file under the `codemods` directory For some reason the `moduleNameMapper` causes an error when running the codemod tests, it results in a `transformer is a not function` type error. In order to avoid this now, I add an empty config file and will investigate the root cause of the issue later. * chore: add a very basic codemod implementation and tests The current codemod is able to change the usages of `useQuery` according to the new API, so it will put the existing parameters into an object and pass it as the only parameter, but that's all. More changes coming soon. * chore: fix `prettier` errors in `use_query` codemod * chore: add missing `export` keywords to test suites in case of `use_query` codemod I just want to avoid `eslint` errors in the IDE. * feat(codemod): add basic codemods for query client methods * feat(codemod): add basic `useQueries` codemods * refactor(codemod): rework `useQuery` related codemods * feat(codemod): move files under `v4` directory We decided to move the version 4 related codemods under a separate directory. * chore(codemod): move `jscodeshift` library from `dependencies` to `devDependencies` Accidentally I added this package under `dependencies` but it should be placed under `devDependencies`. * chore(codemod): pick up codemods test by `npm test` From now the `npm test` command will execute the codemod tests as well. * refactor(codemod): remove `without-parameter` test case in case of `queryClient` related codemods This test case is not useful at all, it just adds extra code. * chore(codemod): remove duplications from `queryClient` codemod testfixtures The number of duplications was just simply too much. It doesn't make any sense to maintain repetitive boilerplate code. * chore(codemod): rename `first-parameter-is-identifier` and `object-expression-parameter` test case * chore(codemod): rework `first-parameter-is-identifier` and `object-expression-parameter` test suites In these two test cases, we should try to collect as many test cases as possible. * chore(codemod): remove duplications from `useQuery` codemod testfixtures The number of duplications was just simply too much. It doesn't make any sense to maintain repetitive boilerplate code. * chore(codemod): add missing methods to the object syntax aware query client codemods The following methods were missing: - fetchInfiniteQuery - fetchQuery - prefetchInfiniteQuery - prefetchQuery * chore(codemod): add some more test cases to the `parameter-is-object` test suite * feat(codemod): add basic `useMutation` codemods * refactor(codemod): rename `queryKey` replacer and error, because now the key name can be parameterized * feat(codemod): add support for template literals * refactor(codemod): rename `object-syntax-aware` test to `query-client-methods` I want to combine two tests into a single one. * refactor(codemod): move testfixtures to the root level of `__testfixtures__` directory * refactor(codemod): combine the two `queryClient` codemods and test suites into a single one * refactor(codemod): move `useMutation` related parts and testfixutes to `useQuery` codemod The plan is to combine all existing codemods into a single one. * refactor(codemod): remove the whole `use_mutation` library Regarding the necessary parts that were moved to the `useQuery` codemod, we don't need the leftover code anymore. * feat(codemod): add support for the following hook calls: - `useIsFetching` - `useIsMutating` * refactor(codemod): move `useQueries` related parts and testfixutes to `useQuery` codemod The plan is to combine all existing codemods into a single one. * refactor(codemod): remove the whole `use_queries` library Regarding the necessary parts that were moved to the `useQuery` codemod, we don't need the leftover code anymore. * refactor(codemod): introduce `transformUseQueryLikeUsages` function Maybe this change will make the code read easier a bit. * refactor(codemod): do some refinements on the following tests: - `parameter-is-identifier` - `parameter-is-object-expression` * fix(codemod): in the case of JS, the string literal might be interpreted as `Literal` So without the additional `Literal` check, the codemod wouldn't be applied. * fix(codemod): remove `type` filter from import declarations This filter seems to be too strict because the codemods were not applied to the `examples` directory. * refactor(codemod): move `QueryClient` related parts and testfixutes to `useQuery` codemod The plan is to combine all existing codemods into a single one. * refactor(codemod): remove the whole `query_client_methods` library Regarding the necessary parts that were moved to the `useQuery` codemod, we don't need the leftover code anymore. * refactor(codemod): simplify entry point of the codemod It makes the code a bit slower, but on the other hand, it makes the code easier to read and understand. * feat(codemod): add basic `QueryCache` codemods * fix(codemod): do not transform array expression query keys We want arrays as query keys, so when the current query key is an array, we don't need to transform it. * fix(examples/playground): fix invalid usage of `invalidateQueries` * feat(codemod): show file path in console warnings * refactor(codemod): remove `use_query` directory We decided to group the codemods by major version numbers instead of types. The reason is simple: we will bundle all necessary transformations into a single file, so the consumers will have to apply only one codemod. Hopefully, it will make the DX better. * refactor(codemod): rename `use-query` to `key-transformation` The original `use-query` name is not valid anymore, because the codemod changes the signature of other function/method calls as well. * refactor(codemod): replace the transformer name in `key-transformation` codemod I renamed the transformer with the test, so the transformer name also needs to be updated in the test file. * chore(codemod): add codemod and utilities to the bundle We want the code mod to be part of the bundle. If it's part of the bundle, the consumers can directly access it through the `node_modules` directory and run it. We just simply would like to increase the DX. * refactor(codemod): rename function I shouldn't have committed this. :') * fix(codemod): keep `typeArguments` of the node It will prevent the removal of type annotations on a function/method call. * refactor(codemod): move `query-cache` test cases to `default-import` We want to cover the default, named, and namespaced imports in the case of `QueryCache` as well. * feat(codemod): add support for named imports in case of `QueryCache` and `useQueryCache` The codemod must be able to transform usages in the case of named imports as well. * fix(codemod): always return `Identifier` instance in case of `findImportIdentifier` of function Previously it returned a string as a default value and it could lead to errors in the code. * feat(codemod): add support for namespaced imports in case of `QueryCache` and `useQueryCache` The codemod must be able to transform usages in the case of namespaced imports as well. * refactor(codemod): re-use the previously written utility functions in the hook call transformer By this, we can achieve the same functionality with less code repetition. * refactor(codemod): re-use the previously written utility functions in the query-client transformer By this, we can achieve the same functionality with less code repetition. * refactor(codemod): rename `hook-call-transformer` to `use-query-like` transformer I think this name describes better the purpose of this transformer. * chore(codemod): add todo about the `react-query` import check We shouldn't transform files that don't contain `react-query` imports. * refactor(codemod): make the `use-query-like-transformer` to look the same as other transformers I just want to follow the structure of other transformers. * fix(codemod): do not log warnings in the test environment Warning the user about the unprocessable query keys is useful in production, but in the test environment, it just makes it more difficult to read the output. * docs(codemod): add instructions how to apply codemods * chore(examples): apply codemod on the `examples` directory * docs(codemod): update `Codemod` section The suggested text sounds better. :) Co-authored-by: Dominik Dorfmeister Co-authored-by: Dominik Dorfmeister * feat: remove idle state (#3302) * feat: remove idle state in favor of status: loading & fetchStatus: idle * feat: remove idle state remove isIdle boolean * feat: remove idle state documentation around the removed idle state and the new fetchingStatus * feat: remove idle state add missing ' to docs * feat(*): add optional logger prop to QueryClient config (#3246) - remove setLogger - add optional `logger` prop to QueryClientConfig - add getLogger public method to QueryClient - add optional `logger` prop to QueryConfig and MutationConfig - add getDefaultLogger function which returns a default logger based on environment, which is used by everything that takes an optional logger in their config - add createQueryClient test util function that uses a mock logger - replace all `new QueryClient` calls with createQueryClient calls - remove mockConsoleError and usages from tests, which are not necessary anymore BREAKING CHANGE: remove setLogger * refactor: turn off error logging in tests the global `clearMocks: true` should make sure that this gets reset after every test * docs(examples): fix optimistic-updates-typescript example * chore(bundling): bundle for modern browsers (#3342) * chore(bundling): update babel dependencies * chore(bundling): remove babel-plugin-transform-async-to-promises we don't use async functions, and we also want to target envs that support async functions * chore(bundling): update supported browsers for a more modern output * chore(bundling): tweak browserslist and exclude transform-parameters plugin, which comes in because of any safari version, even though it should not be needed according to caniuse. This plugin transforms ES2015 parameters to ES5, this includes: Destructuring parameters, Default parameters and Rest parameters, all of which are supported by Safari * chore(bundling): update terser * chore(bundling): fix tests ReferenceError: Cannot access 'promiseResolve' before initialization * chore(bundling): docs about supported browsers * chore(bundling): small docs fixes * chore: eslint no-unnecessary-condition (#3344) * chore(eslint): turn on no-unnecessary-condition rule * chore(eslint): turn on no-unnecessary-condition rule remove unnecessary optional chainings in tests * chore(eslint): keep the matchMedia check even though it can never be undefined, except in tests, and I couldn't figure out how to mock that properly * chore(eslint): remove unnecessary checks in devtools * chore(eslint): addEventListener should exist on window if window is defined, which is checked by isServer * chore(eslint): assign default object to options instead of re-assigning it. In any case, the optional chaining is unnecessary * chore(eslint): action.type should always be defined * chore(eslint): keep the fallback for console * chore(eslint): one rule always complains so up-casting false to boolean * chore(eslint): if we have a behaviour, we also have na onFetch * chore(eslint): parseFilters always returns an object as it falls back to an empty object internally, so the falsy check didn't do anything * chore(eslint): upcast previous result to be potentially undefined to make the optinal chains necessary * fix issues after updating to alpha * fix(mutations): avoid infinite loading states if callbacks return an error (#3343) * fix(mutations): avoid infinite loading states if callbacks return an error add failing test cases * fix(mutations): avoid infinite loading states if callbacks return an error by making sure we always dispatch the error to go to error state internally; re-writing to async-await because it has better support than promise.finally, and the flow is also easier to reason about here * fix(mutations): fix merge conflicts * fix(react-native): bring back check for window.addEventListener (#3345) because it does not exist in RN, but window is defined * refactor(queryObserver): get rid of double-defaulting of options in getOptimisticResult every call to getOptimisticResult already contains defaulted options, which we can enforce on type level by only accepting DefaultedQueryObserverOptions * fix(createAsyncStoragePersister): persistClient respects throttleTime (#3331) (#3336) * docs: update persistQueryClient.md with Persister docs (#3356) * docs: add idb example * docs: consolidate sections storing ~> persistQueryClientSave restoring ~> persistQueryClientRestore * docs: create section for persisters * docs: focus cacheTime docs persistQueryClient and createWebStoragePersister are unrelated * docs: add tip for indexed db * docs: cleanup intro * docs: note additional interfaces available * docs: reorder api to be more intuitive * docs: improve wording * docs: add Offline React Query post (#3320) * docs: multi-line code snippet for layout on mobile * fix(mutations): allow passing a function to useErrorBoundary (#3390) * docs: idle state is removed * feat: Support the ability to provide a context (#2548) * Support providing a context * Addressing comments and merge conflicts from rebase * feat(persistQueryClient): PersistQueryClientProvider (#3248) * feat(persistQueryClient): PersistQueryClientProvider * feat(persistQueryClient): PersistQueryClientProvider defer subscription if we are hydrating * feat(persistQueryClient): PersistQueryClientProvider make sure we do not subscribe if the component unmounts before restoring has finished * feat(persistQueryClient): PersistQueryClientProvider make unsubscribe a const so that we don't mutate what we've exposed * feat(persistQueryClient): PersistQueryClientProvider make hydrating queries go in fetchStatus: 'idle' instead of paused because paused means we have started fetching and are pausing, and we will also continue, while with hydration, we haven't started fetching, and we also might not start if we get "fresh" data from hydration * feat(persistQueryClient): PersistQueryClientProvider don't export IsHydratingProvider, as it shouldn't be needed by consumers * feat(persistQueryClient): PersistQueryClientProvider provide onSuccess and onError callbacks to PersistQueryClientProvider so that you can react to the persisting having finished, to e.g. have a point where you can resumePausedMutations * feat(persistQueryClient): PersistQueryClientProvider tests for onSuccess callback, and remove onError callback, because the persister itself catches errors and removes the store * feat(persistQueryClient): PersistQueryClientProvider test for useQueries * feat(persistQueryClient): PersistQueryClientProvider docs * make restore in mockPersister a bit slower to stabilize tests * better persistQueryClient docs * feat(PersistQueryClientProvider): make sure we can hydrate into multiple clients and error handling * offline example * extract to custom hook * remove onError callback because errors are caught internally by persistQueryClient and the persisted client is then removed * just ignore stale hydrations if the client changes * Revert "just ignore stale hydrations if the client changes" This reverts commit 91e2afb7ba5b08dc86a188d7b9b21d07a8e3c440. * just ignore stale hydrations if the client changes this makes sure we only call onSuccess once, for the "latest" client * since QueryClientProviderProps is now a union type, we can't extend it from an interface * feat(cacheTime): default cacheTime to Infinity for SSR (#3377) * feat(cacheTime): default cacheTime to Infinity for SSR Cache persists for the lifecycle of request and can be immediately GCed afterward Helps close Node process immediately after use * docs: Add default server-side cacheTime to migration docs * docs(examples): fix offline example (#3463) * docs(examples): remove non-existing / unused imports * docs(examples): add missing msw dependency and fix some more things * fix(persistQueryClient): subscribe to both QueryCache and MutationCache * feat: add support for react 18 * feat(react): react-18 update react dependencies and add use-sync-external-store polyfill * feat(core): react-18 use a version of uSES that actually has an implementation other than "Not Yet Implemented" * feat(core): react-18 looks like we also need the experimental version of react, because v18-alpha doesn't support uSES yet. * feat(core): react-18 update testing-library to v13 alpha * feat(core): react-18 do not update currentResult when it is equal to the previousResult, because we use the currentResult as snapshot for uSES, so it must be as stable as possible * feat(core): react-18 switch forceUpdate with uSES. - I'm not sure if the `updateResult` effect is still necessary, or if it's guaranteed that we can't miss any updates because we don't subscribe in an effect anymore; tests behave the same with / without it - tbd - subscribe must be stable, or else we wind up in an infinite loop. in order to be able to pass `observer.subscribe`, we must bind the function in the constructor * feat(core): react-18 make the first test a bit more stable - we don't want more than 2 results * feat(core): react-18 fix type issues in devtools tests, so we adhere to the new typings of testing-library v13 * feat(core): react-18 make devtools test more resilient: act throws an error in the latest version if used liked that, but we don't need it. We can just click the button and use waitFor, as documented here: https://testing-library.com/docs/guide-disappearance#2-using-waitfor * feat(core): react-18 don't re-assign result * feat(core): react-18 bring back the optimistic result; this is debatable because it means we actually _ignore_ whe result returned by uSES, but it makes for fewer re-renders as we can go back to silently update from the effect * feat(core): react-18 useIsFetching to uSES I don't fully understand the test that needed adaption, but the new numbers actually look more correct. The first thing that happens is showing the SecondQuery (after 50ms), and at that time, the FirstQuery is already fetching, so why should there be two zeros in the result array ... judging from the console mock assertion, we are testing if state hasn't been updated on an unmounted component, which now can't happen anymore with uSES, so we can remove it * feat(core): react-18 useIsMutatating to uSES As a positive side-effect, there seem to be fewer re-renders now - the new numbers in the tests do make sense * feat(core): react-18 useMutation to uSES one big change is moving `setOptions` into a useEffect - similar to what `useQuery` is doing. However, we have no `getOptimisticResult` in useMutation, so we'll have to see how this behaves the tests need some love - it's generally working, but the way the tests are written, we're getting some failure. * feat(core): react-18 wait for heading to to to value `3` before asserting the onSuccess / onSettled calls * feat(core): react-18 rewrite test to getByRole * feat(core): react-18 since we're not returning anything from onError or onSettled in the tests, the mutation updates the data on the screen before the callbacks have finished running, which is why the test needs to waitFor the callbacks to have been called * feat(core): react-18 work around console error from uSES by moving the console mock to the client part and / or increasing the assertion count for now * feat(core): react-18 there seems to be one less rendering, likely because of batching, getting rid of one render that has the same assertions as the previous state, which is nice * feat(core): react-18 update shim * feat(core): react-18 update to v18 alpha, which should had the native uSES impl * feat(core): react-18 bump uSES * feat(core): react-18 count renders correctly by incrementing the count in useEffect * feat(core): react-18 bump everything and import from /shim * feat(core): react-18 make test more resilient by not using fireEvent * feat(core): react-18 use findByText for more resilient tests * feat(core): react-18 test against react 17 and react 18 * feat(core): react-18 only run bundlewatch once * feat(core): react-18 give a better name * feat(core): react-18 useQueries to uSES * feat(core): react-18 really upgrade react (with exact versions, because alphas) * feat(core): react-18 remove version logging * feat(core): react-18 remove fixed version in test:ci script * feat(core): react-18 try to get rid of warning in suspense test * feat(core): react-18 remove wrongful mock assertion - uSES should not console.error anymore * feat(core): react-18 add missing server-side snapshots * feat(core): react-18 fix build, error is: [!] Error: 'useSyncExternalStore' is not exported by node_modules/use-sync-external-store/shim/index.js, imported by src/react/useIsFetching.ts https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module * 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) * feat(core): react-18 bump dependencies to beta * feat(core): react-18 fix assertions about special react markup * feat(core): react-18 try to make ssr hydration tests work, but skip them for now * feat(core): react-18 bring back batching. for this to work, we need to batch the actual calls to `onStoreChange` received from uSES, and scheduleMicroTask also needs to defer one tick with setTimeout (couldn't find a better way) * feat(core): react-18 reduce timeout to make test less flaky * feat(core): react-18 fix useIsMutating tests: The same value can't really appear twice in the array because re-renders are batched; this seems like a nice improvement due to uSES * feat(core): react-18 make tests slower; it seems that batching together with a sleep(0) actually batches fast responses together, so we now go directly from idle to success * 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 * 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 https://github.com/tannerlinsley/react-query/pull/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 * feat(core): react-18 make ssr tests work in react 18: the updated fetch count is actually correct, as we always fetch once on the server, then sometimes another time on the client. see also this discussion: https://github.com/TkDodo/react-query/pull/2/files#r751305071 * feat(core): react-18 try to make tests work in 17 and 18 because of the different batching, we sometimes get different results, which we can avoid by making the tests really async and do some data fetching that takes at least some time, and write the tests more resilient * feat(core): react-18 resilient tests * refactor(persistQueryClient): Make persistQueryClient stable (#2961) * :truck: Remove experimental from persist-query-client * :truck: Rename persistor -> persister * ✏️ Fix Persistor -> Persister in imports * :truck: Update name in rollup config * :truck: 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 * feat(core): react-18 continue to stabilize tests * 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 a34b4720675dad5ee6ebde401639f328c0c83122. 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) * :fire: 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 * :bug: Fix linking in documentation * :pencil: Fix grammatical errors in docs Co-authored-by: Dominik Dorfmeister * :refactor: Use abortSignal for query cancellation in InfiniteQueryBehavior * 🚨 Fix lint errors * :recycle: Move define signal property to a separate function Co-authored-by: Dominik Dorfmeister * remove test that doesn't make sense anymore - we don't allow different falsy query keys now * feat(core): react-18 re-add missing import after merge conflicts * feat(core): react-18 we need to observe isFetching to get a re-render with it thanks to tracked queries being on per default now * feat(core): react-18 observe fields we are actually checking * feat(core): react-18 stabilize tests * feat(core): react-18 make one specific test assert differently for react17/18 because batching with uSES works slightly differently I think * feat(core): react-18 remove now unnecessary useEffect: uSES makes sure that we can't miss any query updates between creating the observer and subscribing to it, even if the shim is used * feat(core): react-18 stabilize useQueries test: since both queries have the same timeout, it seems that the initial updates are now batched, leading to 1 less re-render * feat(core): react-18 stabilize useQueries test: a little less rerenders * feat(core): react-18 stabilize useInfiniteQuery tests * feat(core): react-18 use setActTimeout in Blink to avoid warning in react17 * feat(core): react-18 nodejs types conflict :/ * feat(core): react-18 always schedule garbage collection instead of removing directly with cacheTime 0, as callbacks might not fire otherwise * ✅ Use getByLabelText for opening query details * :bug: Use findBy* instead of getBy* * feat(core): react-18 wait for button to appear before clicking it * feat(core): react-18 seems like a broke a cacheTime: 0 test with the latest changes that I can't fix even with making the test more stable, so I'm partially reverting that change. However, we really shouldn't call `remove` directly, but always `optionalRemove` to never remove fetching queries. * feat(core): react-18 okay, lets go back to always instantly removing if we have 0 cacheTime. Not sure why the optionalRemove breaks a test * feat(core): react-18 stabilize flaky test - some renders seem to be batched if we don't sleep enough * feat(core): react-18 adapt scheduleMicroTask: we don't need to defer error throwing anymore now that we always defer with sleep(0) initially, which means the test only needs to assure that the callback is not invoked immediately, but deferred by one Promise "tick" * feat(core): react-18 fix suspense tests: since scheduleMicroTask now always defers by a promise tick (setTimeout(0)), and callbacks are batched into this, it takes one tick longer until the callbacks are invoked; we can "fix" that with a sleep(0) in the tests, or just by using waitFor to wait until the callbacks have been called * ✅ Make sorting test more robust * ✅ Make queries dependent on each other * 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 a647f64a051ca4c02a872e7871b4b2ce49aeda2c. * 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 * feat(core): react-18 fix new devtools test * feat(core): react-18 stabilize flaky test * feat(core): react-18 stabilize flaky test * refactor(queryClient): remove undocumented methods * feat(core): react-18 stabilize test: make sure we wait until we have really removed the data before we go online * feat(core): react-18 stabilize test with a sleep ¯\_(ツ)_/¯ * feat(core): react-18 add a dedicated script to test against react v17 * feat(core): react-18 queries need more "distance" between them to not be batched together and so that we get the expected render results in v17 and v18. if queries return faster, results will be batched, resulting in fewer re-renders, which is also good * feat(core): react-18 remove test about "unmounted" warning because we now uSES * feat(core): react-18 wrap update from inside useEffect in act, and make sure the queryFn doesn't return undefined * feat(core): react-18 devtools to uSES; since we have no stable snapshot - Object.values is always a new array, and queryCache.getAll() only changes if we add or remove things - we use the ref to let the getSnapshot function create a new array every time we have received an update from the subscription to trigger a re-render * feat(core): react-18 make devtools work in 18, but that brings back the act warnings in 17 * feat(core): react-18 stabilize another test * feat(core): react-18 stabilize tests: make sure that we wait for the test to finish to get rid of the act warning in 17 * feat(core): react-18 disable 3 ssr-hydration tests in react17 env. they use the shim, which uses layout effect under the hood if window is available, which doesn't work when rendering on the server; I've tried a lot to "mock" the correct environment, but to no success; the test will still run fine under react18 env, so I think we're good here * feat(core): react-18 flaky test much * feat(core): react-18 fix flaky test: we actually expect a length of two here, because suspense takes care of the intermediate loading state * feat(core): react-18 slowdown test some more to decrease flakyness * feat(core): react-18 simplify keepPreviousData tests. we are asserting all intermediate data steps anyways, and we don't really care about the intermediate fetching steps. exact batching happens depending on speed of the test / shim being used or not etc. Sometimes, intermediate steps are batched together into one re-render, which is not a bad thing. We would have to make the tests really slow to be super predictable though * 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 * feat(core): react-18 there seems to be one less re-render, consistently, with this test * 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 * feat(core): react-18 fix merge conflict * feat(core): react-18 remove duplicate test (introduced in merge conflict) * feat(core): react-18 flaky test * feat(core): react-18 try to make flaky test more stable * :recycle: Refactor devtools subscriptions * :sparkles: Move query states subscriptions to separate component * :recycle: Move active query to a separate component * feat(core): react-18 update to react-18 rc * feat(core): react-18 get rid of unused ts-expect-error, as we now have access to process.env * feat(core): react-18 tests: switch from .click() to fireEvent.click to avoid act warnings * feat(core): react-18 tests: fix suspense act warning * feat(core): react-18 use fireEvent.click() for tests because of act warnings * fix merge conflicts * more merge conflicts * another merge conflict: idle state doesn't exist anymore * fix tests, we need to check for fetchStatus now * remove unnecessary optional chaining in tests * prettier * useIsMutating: fix assertions - no more duplicates in react18 * also, no duplicate renderings for PersistQueryClient anymore * make tests more resilient don't wait for a specific time and then get, just try to find the text at all (timing with react18 can be different) * another flaky one * re-write new custom context tests to be the same as other tests * re-write new custom context tests to be the same as other tests * remove calls to getServerSnapshot it's optional and we don't do anything meaningful as of now in it; will need to re-add it once we do react18 hydration * Revert "remove calls to getServerSnapshot" This reverts commit eabcd4667523fbe44497a5e56815c9aa9b894f6a. * update to latest alphas an rcs * use testing-library 12 for react-17 test suite because the latest alpha dropped support for react17 * update from release candidates to actual releases * make another test more stable Co-authored-by: Eddy Co-authored-by: Eddy Vinck Co-authored-by: Prateek Surana Co-authored-by: Rene Dellefont * chore: release beta docs * docs: fix suspense example (#3458) * docs: fix suspense example * docs: fix useTransition interface * docs: fix suspense example * docs: fix useTransition interface Co-authored-by: Nika Sepiskveradze * docs(examples): update examples to use react18 (#3466) * tests: really assert that filtering works by checking that we never had two isFetchings * docs(examples): update react-scripts based examples to react18 and rq v4-beta * docs(examples): use react-query v4 in all examples * docs(examples): remove old version of persistence and use the dedicated provider instead * docs: use createRoot in the docs * docs(examples): fix import of createWebStoragePersister * docs(examples): make offline example a bit better * docs(QueryClient): fix indentation * fix(types): use react 18 types (#3482) * fix(types): fix promise inference in useQueries (#3493) * fix(types): handle Promise inference in useQueries * fix(types): prettier * docs(v4): update context example in v4 migration guide * test: stabilize new test * test: stabilize some more tests * fix(persistQueryClient): rename isHydrating to isRestoring (#3512) * fix(devtools): devtools should not import relatively from react-query * fix(hydration): properly remove unused hydration entry point hydration moved to the core, and the build entry point was already removed for v4. this is just a proper cleanup. * fix(persistQueryClient): rename isHydrating to isRestoring as we currently have no plans to re-use this for useHydrate, it would be confusing to not get true for this value in those cases * fix(persistQueryClient): document useIsRestoring * fix: make QueryErrorResetBoundary value stable we want a constant value for the lifetime of the QueryErrorResetBoundary component; useMemo doesn't guarantee that. * chore: remove resolutions from package.json as discussed here: https://github.com/tannerlinsley/react-query/pull/2688#discussion_r851847721 * fix: log message we don't have a queryKey at this point if a string was used due to how the overloads try to spread things * Update docs/src/pages/plugins/persistQueryClient.md * docs: fix offline example * fix: ESM compliant bundling (#3521) * fix various bundling issues * add package.json to exports * remove @svgr/rollup * remove node v12 from CI * support devtools/development * do not alias react-query * add side effect * remove "module" * fix * fix exports * add "module" * update @babel/runtime * don't preserve modules * switch back to babel * add migration note * update babel * update rollup * downgrade @rollup/plugin-commonjs * fix: Use fully-specified path to import use-sync-external-store/shim (#3561) * fix: move usage of React Context out of core package (#3578) * refactor: move test utils out of reactjs so that we can import them in core * refactor: move react specific utils back to reactjs * refactor: adapt test imports * refactor: move two tests to the reactjs package because they render a component * chore: setup eslint import zones so that we can't import anything into `core` that lives in other packages, like reactjs * fix: move usage of React Context out of core package by keeping HydrateOptions separate from React, and only add ContextOptions where necessary * fix: type issue when void or undefined is returned from query function (#3541) * fix(types): fix handling of promise return type in QueryFunctionData * fix(QueryFunction): return type restrict void and avoid union type distribution * fix(QueryClient): make setQueryDefaults compatible with adjusted QueryFunction type * fix(useQueries): correct type inferrence in GetResults with new QueryFunction type * fix(tests): adjust all test cases which use any or never as query function return type to comply with new QueryFunction type * fix(tests): change incorrect query function return types of query tests from string to unknown * feature(useQuery): add test cases covering void and Promise return types * feature(useQueries): reject void or undefined as query function return type * feature(useQueries): add test cases for invalid query function return types * fix tsc error after rebasing lastest beta branch * fix: uSES import for react-native / esm (#3601) * fix(query): updating with setQueryData should not affect fetchStatus (#3613) queries can be fetching _while_ we are making a manual update are still fetching, so we have to set fields that affect the fetch conditionally (fetchStatus, fetchFailureCount) * chore: bump uSES to 1.1.0 (#3614) * fix(queryClient): make sure that setQueryData can return undefined from the updater function on type level (#3615) the only runtime tests we had didn't use the previous value, so the generic defaults to unknown; the TS error becomes apparent when providing a generic to setQueryData * docs: point offline example to /beta * feat(persistQueryClient): persist error handling (#3556) * refactor: remove type-fest as a dependency only used for the Promisable type, which is easy to recreate * feat(persistQueryClient): error handling strategies for persist plugins * feat(persistQueryClient): error handling strategies for persist plugins adapt tests * make handlePersistError return null to stop retries if null is returned, which is also the default strategy, the webstorage entry will be removed completely. * test for default behaviour * async version for persist error handling to make sync and async compatible, persist version must also throw an error to abort * make sure that async persister can accept sync error handlers * undefined errorStrategy, or return undefined from it, will just not persist anymore * rename to retry + documentation * improve docs * docs: update typescript.md * fix: make sure isDataEqual option is respected everywhere where we use structuralSharing (#3643) * fix(infiniteQuery): do not consume AbortSignal unless user has consumed it (#3507) * fix(infiniteQuery): do not consume AbortSignal unless user has consumed it calling context.signal?.addEventListener did consume the signal * fix(infiniteQuery): do not consume AbortSignal unless user has consumed it fix formatting * re-write test to reflect the reality we want to continue fetching pages in the background even if the infinite query unmounts, unless the abort signal has been consumed. That is the documented behaviour, and also what useQuery is doing. * fix test * fix: useSyncExternalStore re-export (#3656) * fix: useSyncExternalStore re-export This is due to esm/cjs interop * fix: useSyncExternalStore re-export also fix react native re-export * test: try to stabilize tests * test: try to stabilize tests * fix(types): make sure queryClient.setQueriesData can return undefined from the updater (#3657) * fix(persist): remove environment check (#3658) because we can now pass in undefined for persisters during SSR, and the persisters themselves are not window related anymore, as we don't use window.localStorage directly * fix(types): remove non-void constraint from queryFn result (#3666) * fix(types): remove non-void constraint from queryFn result * test(types): remove non-void tests, and add tests for handling fetch -> promise * test(types): remove ts-expect-error from query test file * feat: make InfiniteQueryObserver's type more robust (#3571) Co-authored-by: 廖璇 * fix: `replaceDeepEqual` special case for non-plain arrays (#3669) * Fix case where replaceDeepEqual was returning incorrect value for non-plain arrays * fix pr comments * docs: restructure migration guide by importance of breaking changes * fix(persist): introduce in-house synchronous Storage interface (#3673) * docs: migrate to tanstack.com * examples: vendor to platform directories * Update index.js * Update config.json * update readme * Update README.md * docs: fix link typo in README.md (#3679) fix: link typo in README.md * docs: Update graphql.md to fix link (#3683) * tests: stabilize we don't care about intermediate results, and they might be render-batched * docs: rewrite typescript docs * docs: adapter teasers * Update config.json * Fix Best of JS badge in README (#3695) * docs: fix the broken links in network-mode.md (#3765) * Update network-mode.md Fix the url for query cancellation * Fix the remaining broken urls in network-mode.md * docs: fix the typo in persistQueryClient.md (#3768) Update subtitle `PeristQueryClientProvider` to `PersistQueryClientProvider`. * yarn -> npm * Monorepo, Rebrand to TanStack (#3708) * rebrand * move to src * chore: fix build by re-exporting types explicitly * chore: run everything through prettier * chore: bring back linting and compilation tasks * chore: setup eslint-import-resolver-typescript it still errors with import/no-unresolved, but I think that's because TS errors as well! * chore: fix a ton of imports * chore: down to zero ts errors * chore: export types separately to make the build work * chore: down to zero eslint issues 🎉 * chore: try to get tests to work * chore: make tests work * fix: use better match sorter primitives * chore: update workflows * Update ci.yml * chore: remove match-sorter dependency * chore: enable bundle size collection * chore: update to latest react * fix(devtools): fix typings of rankItems not sure if that is correct now... * chore: fix compilation * tests: fix tests by removing weird comment that is no longer necessary after upgrading react * tests: remove incrompehensible tests I don't know what these tests are doing, but overwriting useEffect is not something that makes sense now that we useSyncExternalStore for data fetching anyways ... * fix(devtools): fix sorting of queries rankItem doesn't take keys, so we have to pass the queryHash in directly to rank it * chore: setup ci pipeline and bundlewatch * chore: build during pr pipelines * chore: remove private:true as requested by CI: Error: Package undefined in /tmp/98d7e7a6 is set to private, remove package.json#private to publish it * Revert "chore: remove private:true" This reverts commit e1b237bf1a19901baf8b55c1d68a5627e27d7660. * chore: turn off import/no-unresolved in tests somehow, that fails in CI, and we have typescript protection against unresolved imports anyhow * fix: turn of import/no-unresolved for all tanstack imports * fix: regex * chore: do not run legacy pipelines on PRs * chore: fix ci check names * chore: add react-17 dependencies * chore: split up ci tasks * fix: building is done via bundlesize reporting so we don't need to build during testing * chore: try to make codesandbox ci work it requires package to be public, but for installing and yarn workspaces, we need it to be private * fix: apply private: false to all workspaces * fix: paths to sandboxes * chore: fix code coverage collection * chore: change imports from react-query to tanstack/react-query * docs: update migration docs with the rebrand * chore: revert codemod changes prettier destroyed the assertions * fix(useIsMutating): we need to subscribe to the right cache this is likely a copy-paste error, and the tests only worked because we render top-down; now, the tests make sure that components are re-rendered because of the subscription itself * Update README.md * docs: devtools documentation for tanstack rebrand * fix builds * chore: cleanup Co-authored-by: Dominik Dorfmeister * chore: small beta fixes (#3800) * chore: fix the test:format and csb install scripts * chore: not sure why there is a lint error in this test... * chore: update lock files * chore: get basic example working again * Revert "chore: get basic example working again" This reverts commit a58472eb0f928edd6a6dc73c3c057e8226b2862a. * Revert "chore: update lock files" This reverts commit 8794f652e9e5059638a1b20f9a40d0f30cb18bf9. * refactor: webStoragPersister -> syncStoragePersister * feat(codemod): add codemod that replaces the react-query import specifiers (#3801) * feat(codemod): add codemod that replaces the react-query import specifiers * feat(codemod): add codemod that replaces the react-query import specifiers update migration docs * feat(codemod): add codemod that replaces the react-query import specifiers re-add yarn installation instructions * docs: Update installation.md (#3799) Update links to simple and basic examples * docs(mutations): fix typos (#3779) * docs: Update for typescript (#3789) Co-authored-by: simple * docs: fix typo in ssr.md (#3748) whereever -> wherever * docs: Update useQueries hook example (#3710) I have used as an example "staleTime: Infinity", but it can be whatever makes sense here. I've had a hard time figuring out where to put my options just by reading the explanation below the code example. * chore: remove yarn.lock we use npm now * chore: fix the build 1) main field was wrong 2) useSyncExternalStore wasn't picked up correctly * fix: add react-dom as peer dependency (#3786) * rebase * react native * rebranded imports (#3803) * refactor: apply import codemod to examples * refactor: update import in typescript example * refactor: more import updates * chore: run prettier over examples * chore: try to setup codesandbox-ci for the monorepo structure * chore: force the use of npm ci in the pipeline * chore: install with leagacy peer deps * chore: try --force instead * chore: re-generate lock file in the hopes that it fixes the install problems * chore: force testing-library to v12.1.4 because 12.1.5 only supports react < 18, and we install both 17 and 18 * chore: try again with legacy peer deps now that only eslint-config is failing * chore: try if removing examples from workspaces changes a damn thing * Revert "chore: try if removing examples from workspaces changes a damn thing" This reverts commit c4be1847224e64599904779b6cdecd53de440d91. * chore: try a specific node version * chore: add dependencies to correct packages * chore: add missing dev dependencies (maybe) * chore: add more top level devDependencies * chore: move jscodeshift to the top, too * chore: try with npm install * chore: run node16 only! * chore: run node16 only * chore: remove devDependencies from top level package.json again root cause seems to be sub-packages not being installed with `npm ci`, so we switched to `npm install` instead * docs: Update installation.md (#3830) update bash install package from *@tanstack/react-query* to *react-query@beta* * feat(types): better type narrowing for useQuery when initialData is supplied (#3834) * Added a proof of concept for initialData * Fleshed out test * Completed overload change * More progress * Testing if a local tsconfig.json quiets down the errors * Fixed TS errors * fix(types): extract DefinedQueryResult and use that in tests * Apply suggestions from code review Co-authored-by: Dominik Dorfmeister * docs(useQuery): add an explanation of isDataEqual option (#3838) * fix(devtools): make sure that sort function is properly read from localStorage (#3703) * fix(devtools): make sure that sort function is properly read from localStorage * test(devtools): wrap getByRole queries with explicit expect statements when the returned element is not used for assertions * chore(devtools): apply prettier formatting * chore: make broadcast-client experimental again (#3816) * chore: beta release (#3815) * chore: remove leftover yarn.lock files we use npm now * chore: pin node version to 16.14.2 * chore: run tests before releasing * chore: make test-and-publish script only run on TanStack/query Co-authored-by: Rene Dellefont Co-authored-by: Anthony Fertil Co-authored-by: Jonathan Stanley Co-authored-by: Eduard Bardají Puig Co-authored-by: GLabat Co-authored-by: Guillaume Labat Co-authored-by: phatmann Co-authored-by: Louis Law Co-authored-by: hverlin Co-authored-by: Balázs Máté Petró Co-authored-by: Anıl Anar Co-authored-by: Alvin Huang Co-authored-by: Mostafa Nawara Co-authored-by: Nick Galloway Co-authored-by: JacobLey <37151850+JacobLey@users.noreply.github.com> Co-authored-by: Eddy Co-authored-by: Eddy Vinck Co-authored-by: Prateek Surana Co-authored-by: Nika Sepiskveradze <62851300+nikasepiskveradze@users.noreply.github.com> Co-authored-by: Nika Sepiskveradze Co-authored-by: Arty <26905074+artysidorenko@users.noreply.github.com> Co-authored-by: Sachin Raja Co-authored-by: Hikari Hayashi Co-authored-by: Yannick Stachelscheid Co-authored-by: Hirbod <504909+hirbod@users.noreply.github.com> Co-authored-by: liaoliao666 <1076988944@qq.com> Co-authored-by: 廖璇 Co-authored-by: moxey.eth Co-authored-by: Fedir Ushakov Co-authored-by: Tanner Linsley Co-authored-by: Young Co-authored-by: Sam Kvale Co-authored-by: Michael Rambeau Co-authored-by: Brad Zickafoose Co-authored-by: 庄宏基 Co-authored-by: Tristan Marsh Co-authored-by: Morley Tatro Co-authored-by: Kim JeongHyeok <42544600+zereight@users.noreply.github.com> Co-authored-by: simple Co-authored-by: Ikko Ashimine Co-authored-by: webbalea <93341350+webbalea@users.noreply.github.com> Co-authored-by: Duarte Nunes Co-authored-by: Eko Setiyo Budi Purnomo <32205313+EkoSetiyo13@users.noreply.github.com> Co-authored-by: Matt Pocock Co-authored-by: airman5573 <68623798+airman5573@users.noreply.github.com> Co-authored-by: Michal Tecza --- .browserslistrc | 12 +- .codesandbox/ci.json | 7 +- .eslintrc | 19 +- .../{test-and-publish.yml => ci-v3.yml} | 19 +- .github/workflows/ci.yml | 30 + .github/workflows/pr.yml | 28 + .gitignore | 11 +- .gitpod.yml | 18 - .nvmrc | 1 + .prettierrc | 5 + .vscode/settings.json | 8 - CONTRIBUTING.md | 125 - LICENSE | 2 +- README.md | 8 +- .babelrc.js => babel.config.js | 20 +- .../package.json | 6 - core/package.json | 6 - .../package.json | 6 - .../package.json | 6 - devtools/development/package.json | 6 - devtools/index.js | 12 - devtools/package.json | 6 - docs/.gitignore | 8 - docs/README.md | 30 - docs/adapters/react-query.md | 37 + docs/adapters/solid-query.md | 10 + docs/adapters/svelte-query.md | 7 + docs/adapters/vue-query.md | 7 + .../{src/pages => }/community/tkdodos-blog.md | 5 + docs/{src/pages => }/comparison.md | 2 +- docs/config.json | 423 + docs/{src/pages => }/devtools.md | 21 +- docs/{src/pages => }/graphql.md | 2 +- .../guides/background-fetching-indicators.md | 2 +- docs/guides/caching.md | 33 + docs/guides/custom-logger.md | 22 + .../guides/default-query-function.md | 5 +- .../pages => }/guides/dependent-queries.md | 24 +- docs/guides/disabling-queries.md | 89 + .../guides/does-this-replace-client-state.md | 0 docs/{src/pages => }/guides/filters.md | 25 +- .../pages => }/guides/important-defaults.md | 0 .../pages => }/guides/infinite-queries.md | 16 +- .../pages => }/guides/initial-query-data.md | 18 +- .../guides/invalidations-from-mutations.md | 6 +- .../guides/migrating-to-react-query-3.md | 16 +- docs/guides/migrating-to-react-query-4.md | 488 + docs/{src/pages => }/guides/mutations.md | 61 +- docs/guides/network-mode.md | 46 + .../pages => }/guides/optimistic-updates.md | 10 +- .../pages => }/guides/paginated-queries.md | 0 .../pages => }/guides/parallel-queries.md | 14 +- .../guides/placeholder-query-data.md | 6 +- docs/{src/pages => }/guides/prefetching.md | 4 +- docs/{src/pages => }/guides/queries.md | 36 +- .../pages => }/guides/query-cancellation.md | 20 +- .../{src/pages => }/guides/query-functions.md | 18 +- .../pages => }/guides/query-invalidation.md | 12 +- docs/{src/pages => }/guides/query-keys.md | 15 +- docs/{src/pages => }/guides/query-retries.md | 6 +- .../pages => }/guides/scroll-restoration.md | 0 docs/{src/pages => }/guides/ssr.md | 24 +- docs/{src/pages => }/guides/suspense.md | 8 +- docs/{src/pages => }/guides/testing.md | 26 +- .../guides/updates-from-mutation-responses.md | 0 .../guides/window-focus-refetching.md | 10 +- docs/{src/pages => }/installation.md | 25 +- docs/jsconfig.json | 5 - docs/next.config.js | 100 - docs/{src/pages => }/overview.md | 4 +- docs/package.json | 85 - .../plugins/broadcastQueryClient.md | 0 .../createAsyncStoragePersister.md} | 34 +- docs/plugins/createSyncStoragePersister.md | 128 + docs/plugins/persistQueryClient.md | 277 + docs/postcss.config.js | 3 - docs/public/images/bytes-logo.png | Bin 93989 -> 0 bytes docs/public/robots.txt | 2 - docs/{src/pages => }/quick-start.md | 6 +- docs/{src/pages => }/react-native.md | 6 +- .../reference/InfiniteQueryObserver.md | 2 +- .../pages => }/reference/MutationCache.md | 8 +- .../pages => }/reference/QueriesObserver.md | 0 docs/{src/pages => }/reference/QueryCache.md | 2 +- docs/{src/pages => }/reference/QueryClient.md | 102 +- .../reference/QueryClientProvider.md | 7 +- .../reference/QueryErrorResetBoundary.md | 2 +- .../pages => }/reference/QueryObserver.md | 2 +- .../{src/pages => }/reference/focusManager.md | 4 +- docs/{src/pages => }/reference/hydration.md | 32 +- .../pages => }/reference/onlineManager.md | 6 +- .../pages => }/reference/useInfiniteQuery.md | 4 +- .../pages => }/reference/useIsFetching.md | 4 +- .../pages => }/reference/useIsMutating.md | 4 +- docs/{src/pages => }/reference/useMutation.md | 16 +- docs/reference/useQueries.md | 26 + docs/{src/pages => }/reference/useQuery.md | 54 +- .../pages => }/reference/useQueryClient.md | 2 +- .../reference/useQueryErrorResetBoundary.md | 2 +- docs/src/components/ArrowRight.js | 10 - docs/src/components/Banner.js | 12 - docs/src/components/BytesForm.js | 49 - docs/src/components/CarbonAds.js | 45 - docs/src/components/CodeBlock.js | 125 - docs/src/components/Container.js | 6 - docs/src/components/DocsPageFooter.js | 76 - docs/src/components/ExternalLink.js | 4 - docs/src/components/Footer.js | 141 - docs/src/components/Highlight.js | 140 - docs/src/components/Highlight2.js | 100 - docs/src/components/LayoutDocs.js | 228 - docs/src/components/LazyImage.js | 25 - docs/src/components/Logo.js | 0 docs/src/components/MDXComponents.js | 8 - docs/src/components/Markdown.js | 10 - docs/src/components/Nav.js | 73 - docs/src/components/PPPBanner.js | 69 - docs/src/components/ProgressiveImage.js | 99 - docs/src/components/Search.js | 56 - docs/src/components/Seo.js | 80 - docs/src/components/Sidebar.js | 52 - docs/src/components/SidebarCategory.js | 126 - docs/src/components/SidebarHeading.js | 23 - docs/src/components/SidebarMobile.js | 112 - docs/src/components/SidebarNavLink.js | 75 - docs/src/components/SidebarPost.js | 46 - docs/src/components/Sticky.js | 26 - docs/src/components/TWButton.js | 97 - docs/src/components/Toc.js | 60 - docs/src/components/Toc.module.css | 13 - docs/src/components/TocNotion.js | 41 - docs/src/components/blog-markdown.module.css | 176 - docs/src/components/blog/ExternalLink.js | 4 - docs/src/components/blog/Heading.js | 37 - docs/src/components/blog/Image.js | 190 - docs/src/components/blog/dynamic.js | 14 - .../blog/intersection-observer/index.js | 1 - .../intersection-observer.js | 105 - .../blog/intersection-observer/manager.js | 65 - .../blog/intersection-observer/utils.js | 53 - docs/src/components/clients/Client.js | 13 - docs/src/components/clients/ClientsMarquee.js | 44 - docs/src/components/clients/Filters.js | 41 - docs/src/components/forwardRefWithAs.js | 66 - docs/src/components/markdown.module.css | 181 - docs/src/components/useBytesSubmit.js | 32 - docs/src/components/useClipboard.js | 26 - docs/src/components/useIsMobile.js | 29 - docs/src/components/useLocalStorage.js | 39 - docs/src/components/useOverScroll.js | 46 - docs/src/components/useSearch.js | 105 - docs/src/components/useTocHighlight.js | 83 - docs/src/components/utils/throttle.js | 14 - docs/src/images/emblem-light.svg | 13 - docs/src/images/favicon.png | Bin 1880 -> 0 bytes docs/src/images/logo.svg | 23 - docs/src/images/logos/walmart.svg | 1 - docs/src/images/react-query-og.png | Bin 202595 -> 0 bytes docs/src/images/react-query-twitter.png | Bin 202595 -> 0 bytes docs/src/lib/docs/findRouteByPath.js | 13 - docs/src/lib/docs/md-loader.js | 22 - docs/src/lib/docs/remark-paragraph-alerts.js | 45 - docs/src/lib/docs/utils.js | 4 - docs/src/lib/fs-utils.js | 4 - docs/src/lib/get-route-context.js | 51 - docs/src/manifests/getManifest.js | 8 - docs/src/manifests/manifest.json | 450 - docs/src/pages/404.js | 11 - docs/src/pages/_app.js | 43 - docs/src/pages/_document.js | 22 - docs/src/pages/examples/auto-refetching.mdx | 25 - .../pages/examples/basic-graphql-request.mdx | 23 - docs/src/pages/examples/basic.mdx | 23 - docs/src/pages/examples/custom-hooks.mdx | 23 - .../pages/examples/default-query-function.mdx | 23 - docs/src/pages/examples/focus-refetching.mdx | 23 - .../examples/load-more-infinite-scroll.mdx | 23 - docs/src/pages/examples/nextjs.mdx | 23 - .../optimistic-updates-typescript.mdx | 23 - .../src/pages/examples/optimistic-updates.mdx | 23 - docs/src/pages/examples/pagination.mdx | 23 - docs/src/pages/examples/playground.mdx | 23 - docs/src/pages/examples/prefetching.mdx | 23 - docs/src/pages/examples/react-native.mdx | 23 - docs/src/pages/examples/rick-morty.mdx | 23 - docs/src/pages/examples/simple.mdx | 23 - docs/src/pages/examples/star-wars.mdx | 23 - docs/src/pages/examples/suspense.mdx | 23 - docs/src/pages/guides/caching.md | 32 - docs/src/pages/guides/disabling-queries.md | 56 - docs/src/pages/index.js | 424 - .../plugins/createWebStoragePersistor.md | 76 - docs/src/pages/plugins/persistQueryClient.md | 136 - docs/src/pages/reference/setLogger.md | 43 - docs/src/pages/reference/useQueries.md | 21 - docs/src/pages/typescript.md | 29 - docs/src/siteConfig.js | 14 - docs/src/styles/blog.module.css | 55 - docs/src/styles/index.css | 247 - docs/src/styles/post.module.css | 42 - docs/src/styles/shared.module.css | 6 - docs/src/users.js | 23 - docs/tailwind.config.js | 62 - docs/typescript.md | 85 + docs/{src/pages/videos.mdx => videos.md} | 0 docs/yarn.lock | 9685 -- examples/auto-refetching/README.md | 6 - examples/basic-typescript/README.md | 6 - examples/basic/README.md | 6 - examples/default-query-function/README.md | 6 - examples/focus-refetching/README.md | 6 - examples/load-more-infinite-scroll/README.md | 6 - .../optimistic-updates-typescript/README.md | 6 - examples/optimistic-updates/README.md | 6 - examples/pagination/README.md | 6 - examples/playground/README.md | 6 - examples/prefetching/README.md | 6 - examples/prefetching/package.json | 19 - .../{ => react}/auto-refetching/.gitignore | 0 examples/react/auto-refetching/README.md | 6 + .../auto-refetching/next.config.js | 0 .../{ => react}/auto-refetching/package.json | 5 +- .../auto-refetching/pages/api/data.js | 0 .../auto-refetching/pages/index.js | 22 +- .../basic-graphql-request/.babelrc | 0 .../basic-graphql-request/.eslintrc | 0 .../basic-graphql-request/.gitignore | 0 .../basic-graphql-request/.prettierrc | 0 .../basic-graphql-request/.rescriptsrc.js | 0 .../react/basic-graphql-request/README.md | 6 + .../react/basic-graphql-request/package.json | 40 + .../basic-graphql-request/public/favicon.ico | 0 .../basic-graphql-request/public/index.html | 0 .../public/manifest.json | 0 .../basic-graphql-request/src/index.js | 10 +- .../{ => react}/basic-typescript/.babelrc | 0 .../{ => react}/basic-typescript/.eslintrc | 0 .../{ => react}/basic-typescript/.gitignore | 0 .../{ => react}/basic-typescript/.prettierrc | 0 .../basic-typescript/.rescriptsrc.js | 0 examples/react/basic-typescript/README.md | 6 + .../{ => react}/basic-typescript/package.json | 10 +- .../basic-typescript/public/favicon.ico | 0 .../basic-typescript/public/index.html | 0 .../basic-typescript/public/manifest.json | 0 .../basic-typescript/src/index.tsx | 49 +- .../basic-typescript/tsconfig.json | 0 examples/{ => react}/basic/.babelrc | 0 examples/{ => react}/basic/.eslintrc | 0 examples/{ => react}/basic/.gitignore | 0 examples/{ => react}/basic/.prettierrc | 0 examples/{ => react}/basic/.rescriptsrc.js | 0 examples/react/basic/README.md | 6 + examples/{ => react}/basic/package.json | 8 +- examples/{ => react}/basic/public/favicon.ico | 0 examples/{ => react}/basic/public/index.html | 0 .../{ => react}/basic/public/manifest.json | 0 examples/{ => react}/basic/src/index.js | 10 +- examples/{ => react}/custom-hooks/.babelrc | 0 examples/{ => react}/custom-hooks/.eslintrc | 0 examples/{ => react}/custom-hooks/.gitignore | 0 examples/{ => react}/custom-hooks/.prettierrc | 0 .../{ => react}/custom-hooks/.rescriptsrc.js | 0 examples/{ => react}/custom-hooks/README.md | 2 +- .../{ => react}/custom-hooks/package.json | 10 +- .../custom-hooks/public/favicon.ico | 0 .../custom-hooks/public/index.html | 0 .../custom-hooks/public/manifest.json | 0 .../custom-hooks/src/hooks/usePost.js | 2 +- .../custom-hooks/src/hooks/usePosts.js | 4 +- .../{ => react}/custom-hooks/src/index.js | 8 +- .../default-query-function/.babelrc | 0 .../default-query-function/.eslintrc | 0 .../default-query-function/.gitignore | 0 .../default-query-function/.prettierrc | 0 .../default-query-function/.rescriptsrc.js | 0 .../react/default-query-function/README.md | 6 + .../default-query-function}/package.json | 9 +- .../default-query-function/public/favicon.ico | 0 .../default-query-function/public/index.html | 0 .../public/manifest.json | 0 .../default-query-function/src/index.js | 12 +- .../{ => react}/focus-refetching/.gitignore | 0 examples/react/focus-refetching/README.md | 6 + .../focus-refetching/next.config.js | 0 examples/react/focus-refetching/package.json | 20 + .../focus-refetching/pages/api/user.js | 0 .../focus-refetching/pages/index.js | 10 +- .../load-more-infinite-scroll/.gitignore | 0 .../react/load-more-infinite-scroll/README.md | 6 + .../load-more-infinite-scroll/next.config.js | 0 .../load-more-infinite-scroll/package.json | 5 +- .../load-more-infinite-scroll/pages/about.js | 0 .../pages/api/projects.js | 0 .../load-more-infinite-scroll/pages/index.js | 20 +- examples/{ => react}/nextjs/.gitignore | 0 examples/{ => react}/nextjs/README.md | 4 +- .../nextjs/components/Header/index.js | 0 .../nextjs/components/InfoBox/index.js | 0 .../nextjs/components/Layout/index.js | 0 .../nextjs/components/PostList/index.js | 0 .../{ => react}/nextjs/components/index.js | 0 examples/{ => react}/nextjs/hooks/index.js | 0 .../nextjs/hooks/usePosts/index.js | 6 +- examples/{ => react}/nextjs/next.config.js | 0 examples/{ => react}/nextjs/package.json | 9 +- examples/{ => react}/nextjs/pages/_app.js | 8 +- .../{ => react}/nextjs/pages/client-only.js | 0 examples/{ => react}/nextjs/pages/index.js | 2 +- examples/{ => react}/nextjs/yarn.lock | 0 examples/{suspense => react/offline}/.babelrc | 0 .../{playground => react/offline}/.eslintrc | 0 .../offline}/.gitignore | 0 .../{rick-morty => react/offline}/.prettierrc | 0 .../offline}/.rescriptsrc.js | 0 examples/react/offline/README.md | 6 + examples/react/offline/package.json | 39 + .../offline}/public/favicon.ico | 0 .../offline}/public/index.html | 0 .../offline}/public/manifest.json | 0 .../react/offline/public/mockServiceWorker.js | 338 + examples/react/offline/src/App.js | 221 + examples/react/offline/src/api.js | 67 + examples/react/offline/src/index.js | 13 + examples/react/offline/src/movies.js | 58 + .../optimistic-updates-typescript}/.gitignore | 0 .../optimistic-updates-typescript/README.md | 6 + .../next-env.d.ts | 0 .../next.config.js | 0 .../package.json | 5 +- .../pages/api/data.js | 0 .../pages/index.tsx | 51 +- .../tsconfig.json | 0 .../optimistic-updates}/.gitignore | 0 examples/react/optimistic-updates/README.md | 6 + .../optimistic-updates/next.config.js | 0 .../optimistic-updates/package.json | 5 +- .../optimistic-updates/pages/api/data.js | 0 .../optimistic-updates/pages/index.js | 28 +- .../pagination}/.gitignore | 0 examples/react/pagination/README.md | 6 + .../{ => react}/pagination/next.config.js | 0 examples/{ => react}/pagination/package.json | 5 +- .../pagination/pages/api/projects.js | 0 .../{ => react}/pagination/pages/index.js | 14 +- examples/{ => react}/playground/.babelrc | 0 .../playground}/.eslintrc | 0 .../playground}/.gitignore | 0 examples/{ => react}/playground/.prettierrc | 0 .../playground}/.rescriptsrc.js | 0 examples/react/playground/README.md | 6 + .../playground}/package.json | 9 +- .../{ => react}/playground/public/favicon.ico | 0 .../playground}/public/index.html | 0 .../playground}/public/manifest.json | 0 examples/{ => react}/playground/src/index.js | 31 +- .../{ => react}/playground/src/styles.css | 0 .../prefetching}/.gitignore | 0 examples/react/prefetching/README.md | 6 + .../{ => react}/prefetching/libs/fetch.js | 0 .../{ => react}/prefetching/next.config.js | 0 .../prefetching}/package.json | 5 +- .../prefetching/pages/[user]/[repo].js | 7 +- .../{ => react}/prefetching/pages/api/data.js | 0 .../{ => react}/prefetching/pages/index.js | 20 +- examples/{ => react}/react-native/.eslintrc | 0 examples/{ => react}/react-native/.gitignore | 0 examples/{ => react}/react-native/.prettierrc | 0 examples/{ => react}/react-native/App.tsx | 6 +- examples/{ => react}/react-native/README.md | 0 examples/{ => react}/react-native/app.json | 0 .../react-native/assets/adaptive-icon.png | Bin .../react-native/assets/favicon.png | Bin .../{ => react}/react-native/assets/icon.png | Bin .../react-native/assets/splash.png | Bin .../{ => react}/react-native/babel.config.js | 0 .../{ => react}/react-native/package.json | 8 +- .../react-native/src/components/Divider.tsx | 2 +- .../src/components/ErrorMessage.tsx | 2 +- .../react-native/src/components/ListItem.tsx | 2 +- .../src/components/LoadingIndicator.tsx | 2 +- .../react-native/src/data/movies.json | 0 .../react-native/src/hooks/useAppState.ts | 0 .../src/hooks/useOnlineManager.ts | 4 +- .../src/hooks/useRefreshByUser.ts | 2 +- .../src/hooks/useRefreshOnFocus.ts | 2 +- .../{ => react}/react-native/src/lib/api.ts | 0 .../src/navigation/MoviesStack.tsx | 2 +- .../react-native/src/navigation/types.ts | 0 .../src/screens/MovieDetailsScreen.tsx | 2 +- .../src/screens/MoviesListScreen.tsx | 4 +- .../{ => react}/react-native/tsconfig.json | 0 examples/{ => react}/react-native/yarn.lock | 0 examples/{ => react}/rick-morty/.babelrc | 0 .../{simple => react/rick-morty}/.eslintrc | 0 .../{simple => react/rick-morty}/.gitignore | 0 .../{simple => react/rick-morty}/.prettierrc | 0 .../rick-morty}/.rescriptsrc.js | 0 examples/react/rick-morty/README.md | 6 + examples/{ => react}/rick-morty/package.json | 8 +- .../{ => react}/rick-morty/public/favicon.ico | 0 .../{ => react}/rick-morty/public/index.html | 0 .../rick-morty}/public/manifest.json | 0 .../rick-morty}/src/App.js | 4 +- .../{ => react}/rick-morty/src/Character.js | 8 +- .../{ => react}/rick-morty/src/Characters.js | 4 +- .../{ => react}/rick-morty/src/Episode.js | 6 +- .../{ => react}/rick-morty/src/Episodes.js | 4 +- examples/{ => react}/rick-morty/src/Home.js | 0 examples/{ => react}/rick-morty/src/Layout.js | 0 examples/{ => react}/rick-morty/src/fetch.js | 0 .../rick-morty}/src/index.js | 4 +- .../{ => react}/rick-morty/src/styles.css | 0 examples/{ => react}/simple/.babelrc | 0 .../{star-wars => react/simple}/.eslintrc | 0 .../{star-wars => react/simple}/.gitignore | 0 .../{star-wars => react/simple}/.prettierrc | 0 .../simple}/.rescriptsrc.js | 0 examples/react/simple/README.md | 6 + .../simple}/package.json | 12 +- examples/react/simple/public/favicon.ico | 1 + examples/react/simple/public/index.html | 38 + .../simple}/public/manifest.json | 0 examples/{ => react}/simple/src/index.js | 16 +- examples/{ => react}/star-wars/.babelrc | 0 .../{suspense => react/star-wars}/.eslintrc | 0 .../{suspense => react/star-wars}/.gitignore | 0 examples/react/star-wars/.prettierrc | 1 + .../star-wars}/.rescriptsrc.js | 0 examples/react/star-wars/README.md | 6 + examples/{ => react}/star-wars/package.json | 10 +- .../{ => react}/star-wars/public/favicon.ico | 0 .../{ => react}/star-wars/public/index.html | 0 .../star-wars}/public/manifest.json | 0 .../star-wars}/src/App.js | 4 +- .../{ => react}/star-wars/src/Character.js | 8 +- .../{ => react}/star-wars/src/Characters.js | 4 +- examples/{ => react}/star-wars/src/Film.js | 6 +- examples/{ => react}/star-wars/src/Films.js | 4 +- examples/{ => react}/star-wars/src/Home.js | 0 examples/{ => react}/star-wars/src/Layout.js | 0 examples/{ => react}/star-wars/src/fetch.js | 0 .../star-wars}/src/index.js | 4 +- examples/{ => react}/star-wars/src/styles.css | 0 examples/react/suspense/.babelrc | 3 + examples/react/suspense/.eslintrc | 7 + examples/react/suspense/.gitignore | 26 + examples/{ => react}/suspense/.prettierrc | 0 examples/react/suspense/.rescriptsrc.js | 37 + .../suspense}/README.md | 0 examples/{ => react}/suspense/package.json | 9 +- .../{ => react}/suspense/public/favicon.ico | 0 .../{ => react}/suspense/public/index.html | 0 examples/react/suspense/public/manifest.json | 15 + .../suspense/src/components/Button.js | 4 +- .../suspense/src/components/Project.js | 2 +- .../suspense/src/components/Projects.js | 4 +- .../suspense/src/components/Spinner.js | 0 examples/{ => react}/suspense/src/index.js | 8 +- examples/{ => react}/suspense/src/queries.js | 0 examples/{ => react}/suspense/src/styles.css | 0 examples/rick-morty/README.md | 6 - examples/simple/README.md | 6 - examples/simple/package.json | 36 - examples/star-wars/README.md | 6 - examples/suspense/README.md | 6 - hydration/package.json | 6 - jest.config.js | 10 - jest.config.ts | 38 + jest.setup.js | 34 +- lerna.json | 6 + media/repo-header.png | Bin 0 -> 273517 bytes old/rollup.config.js | 106 + package-lock.json | 75288 ++++++++++++++++ package.json | 226 +- .../query-async-storage-persister/.eslintrc | 6 + .../package.json | 25 + .../src/__tests__/asyncThrottle.test.ts | 127 + .../src/asyncThrottle.ts | 58 + .../src/index.ts | 105 + .../tsconfig.json | 9 + .../.eslintrc | 6 + .../package.json | 28 + .../src}/index.ts | 27 +- .../tsconfig.json | 9 + .../yarn.lock | 25 + packages/query-core/.eslintrc | 6 + packages/query-core/package.json | 25 + .../query-core/src}/focusManager.ts | 14 +- .../query-core/src}/hydration.ts | 24 +- .../core => packages/query-core/src}/index.ts | 11 +- .../query-core/src}/infiniteQueryBehavior.ts | 69 +- .../query-core/src}/infiniteQueryObserver.ts | 72 +- packages/query-core/src/logger.native.ts | 11 + packages/query-core/src/logger.ts | 9 + packages/query-core/src/mutation.ts | 349 + .../query-core/src}/mutationCache.ts | 83 +- .../query-core/src}/mutationObserver.ts | 20 +- packages/query-core/src/notifyManager.ts | 96 + .../query-core/src}/onlineManager.ts | 10 +- .../query-core/src}/queriesObserver.ts | 161 +- .../core => packages/query-core/src}/query.ts | 490 +- .../query-core/src}/queryCache.ts | 47 +- .../query-core/src}/queryClient.ts | 356 +- .../query-core/src}/queryObserver.ts | 303 +- packages/query-core/src/removable.ts | 37 + packages/query-core/src/retryer.ts | 215 + .../query-core/src}/subscribable.ts | 9 +- .../src}/tests/focusManager.test.tsx | 24 +- .../query-core/src}/tests/hydration.test.tsx | 213 +- .../src}/tests/infiniteQueryBehavior.test.tsx | 22 +- .../src}/tests/infiniteQueryObserver.test.tsx | 18 +- .../src/tests/mutationCache.test.tsx | 260 + .../src}/tests/mutationObserver.test.tsx | 6 +- .../query-core/src}/tests/mutations.test.tsx | 92 +- .../src}/tests/notifyManager.test.tsx | 22 +- .../src}/tests/onlineManager.test.tsx | 24 +- .../src}/tests/queriesObserver.test.tsx | 123 +- .../query-core/src}/tests/query.test.tsx | 229 +- .../query-core/src}/tests/queryCache.test.tsx | 76 +- .../src}/tests/queryClient.test.tsx | 638 +- .../src}/tests/queryObserver.test.tsx | 185 +- .../query-core/src}/tests/utils.test.tsx | 111 +- .../core => packages/query-core/src}/types.ts | 203 +- .../core => packages/query-core/src}/utils.ts | 162 +- packages/query-core/tsconfig.json | 9 + .../query-sync-storage-persister/.eslintrc | 6 + .../query-sync-storage-persister/package.json | 25 + .../src/__tests__/storageIsFull.test.ts | 157 + .../query-sync-storage-persister/src/index.ts | 111 + .../tsconfig.json | 9 + packages/react-query-devtools/.eslintrc | 6 + packages/react-query-devtools/package.json | 30 + .../react-query-devtools/src}/Explorer.tsx | 22 +- .../react-query-devtools/src}/Logo.tsx | 0 .../src/__tests__}/Explorer.test.tsx | 4 +- .../src/__tests__/devtools.test.tsx | 766 + .../src/__tests__}/utils.tsx | 53 +- .../react-query-devtools/src}/devtools.tsx | 924 +- .../react-query-devtools/src}/index.ts | 0 packages/react-query-devtools/src/noop.ts | 7 + .../src}/styledComponents.ts | 6 +- .../react-query-devtools/src}/theme.tsx | 3 +- .../src}/useLocalStorage.ts | 12 +- .../src}/useMediaQuery.ts | 8 +- .../react-query-devtools/src}/utils.ts | 71 +- packages/react-query-devtools/tsconfig.json | 9 + packages/react-query-persist-client/.eslintrc | 6 + .../react-query-persist-client/package.json | 25 + .../src/PersistQueryClientProvider.tsx | 55 + .../PersistQueryClientProvider.test.tsx | 538 + .../src/__tests__/persist.test.tsx | 48 + .../react-query-persist-client/src/index.ts | 3 + .../react-query-persist-client/src/persist.ts | 165 + .../src/retryStrategies.ts | 30 + .../react-query-persist-client/tsconfig.json | 9 + packages/react-query/.eslintrc | 6 + packages/react-query/__tests__/jest.setup.js | 1 + packages/react-query/codemods/jest.config.js | 3 + .../__testfixtures__/default-import.input.tsx | 94 + .../default-import.output.tsx | 96 + .../__testfixtures__/named-import.input.tsx | 96 + .../__testfixtures__/named-import.output.tsx | 98 + .../namespaced-import.input.tsx | 86 + .../namespaced-import.output.tsx | 88 + .../parameter-is-identifier.input.tsx | 49 + .../parameter-is-identifier.output.tsx | 49 + .../parameter-is-object-expression.input.tsx | 128 + .../parameter-is-object-expression.output.tsx | 175 + .../replace-import-specifier.input.tsx | 10 + .../replace-import-specifier.output.tsx | 10 + .../__testfixtures__/type-arguments.input.tsx | 25 + .../type-arguments.output.tsx | 31 + .../v4/__tests__/key-transformation.test.js | 34 + .../replace-import-specifier.test.js | 14 + .../codemods/v4/key-transformation.js | 138 + .../codemods/v4/replace-import-specifier.js | 25 + .../react-query/codemods/v4/utils/index.js | 166 + .../v4/utils/replacers/key-replacer.js | 160 + .../transformers/query-cache-transformer.js | 115 + .../transformers/query-client-transformer.js | 49 + .../use-query-like-transformer.js | 32 + .../v4/utils/unprocessable-key-error.js | 8 + packages/react-query/package.json | 63 + .../react-query/src}/Hydrate.tsx | 12 +- .../react-query/src}/QueryClientProvider.tsx | 45 +- .../src}/QueryErrorResetBoundary.tsx | 4 +- .../src/__tests__}/Hydrate.test.tsx | 117 +- .../__tests__}/QueryClientProvider.test.tsx | 97 +- .../QueryResetErrorBoundary.test.tsx | 109 +- .../src/__tests__}/ssr-hydration.test.tsx | 159 +- .../react-query/src/__tests__}/ssr.test.tsx | 41 +- .../src/__tests__}/suspense.test.tsx | 239 +- .../src/__tests__}/useInfiniteQuery.test.tsx | 579 +- .../src/__tests__/useIsFetching.test.tsx | 274 + .../src/__tests__/useIsMutating.test.tsx | 260 + .../src/__tests__/useMutation.test.tsx | 1099 + .../src/__tests__/useQueries.test.tsx | 1107 + .../src/__tests__}/useQuery.test.tsx | 2252 +- .../src/__tests__/useQuery.types.test.tsx | 157 + packages/react-query/src/__tests__/utils.tsx | 45 + .../react-query/src}/index.ts | 30 +- packages/react-query/src/isRestoring.tsx | 6 + .../src}/reactBatchedUpdates.native.ts | 0 .../react-query/src}/reactBatchedUpdates.ts | 2 +- .../react-query/src}/setBatchUpdatesFn.ts | 2 +- .../react-query/src}/types.ts | 71 +- .../react-query/src}/useBaseQuery.ts | 101 +- .../react-query/src}/useInfiniteQuery.ts | 29 +- packages/react-query/src/useIsFetching.ts | 39 + packages/react-query/src/useIsMutating.ts | 43 + .../react-query/src}/useMutation.ts | 103 +- .../react-query/src}/useQueries.ts | 122 +- packages/react-query/src/useQuery.ts | 104 + .../react-query/src}/utils.ts | 9 +- packages/react-query/tsconfig.json | 9 + persistQueryClient-experimental/package.json | 6 - prettier.config.js | 12 - react/package.json | 6 - rollup.config.js | 103 +- rollup.config.ts | 254 + scripts/config.ts | 57 + scripts/fix-package-json.js | 20 + scripts/publish.ts | 637 + scripts/tsconfig.json | 20 + scripts/types.ts | 48 + src/core/logger.ts | 21 - src/core/mutation.ts | 339 - src/core/notifyManager.ts | 100 - src/core/retryer.ts | 216 - src/core/tests/mutationCache.test.tsx | 132 - .../index.ts | 92 - .../index.ts | 110 - .../tests/storageIsFull.test.ts | 175 - src/devtools/tests/devtools.test.tsx | 439 - src/hydration/index.ts | 15 - src/index.ts | 2 - src/persistQueryClient-experimental/index.ts | 91 - src/react/logger.native.ts | 7 - src/react/logger.ts | 3 - src/react/setLogger.ts | 4 - src/react/tests/logger.native.test.tsx | 9 - src/react/tests/useIsFetching.test.tsx | 187 - src/react/tests/useIsMutating.test.tsx | 161 - src/react/tests/useMutation.test.tsx | 586 - src/react/tests/useQueries.test.tsx | 1057 - src/react/tests/utils.tsx | 88 - src/react/useIsFetching.ts | 74 - src/react/useIsMutating.ts | 52 - src/react/useQuery.ts | 56 - src/ts3.8/index.ts | 4 - src/ts3.8/useQueries.ts | 6 - tests/utils.ts | 78 + tsconfig.base.json | 38 + tsconfig.json | 31 +- tsconfig.types.json | 23 - yarn.lock | 8264 -- 657 files changed, 93879 insertions(+), 33161 deletions(-) rename .github/workflows/{test-and-publish.yml => ci-v3.yml} (74%) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pr.yml delete mode 100644 .gitpod.yml create mode 100644 .nvmrc create mode 100644 .prettierrc delete mode 100644 .vscode/settings.json delete mode 100644 CONTRIBUTING.md rename .babelrc.js => babel.config.js (64%) delete mode 100644 broadcastQueryClient-experimental/package.json delete mode 100644 core/package.json delete mode 100644 createAsyncStoragePersistor-experimental/package.json delete mode 100644 createWebStoragePersistor-experimental/package.json delete mode 100644 devtools/development/package.json delete mode 100644 devtools/index.js delete mode 100644 devtools/package.json delete mode 100644 docs/.gitignore delete mode 100644 docs/README.md create mode 100644 docs/adapters/react-query.md create mode 100644 docs/adapters/solid-query.md create mode 100644 docs/adapters/svelte-query.md create mode 100644 docs/adapters/vue-query.md rename docs/{src/pages => }/community/tkdodos-blog.md (91%) rename docs/{src/pages => }/comparison.md (96%) create mode 100644 docs/config.json rename docs/{src/pages => }/devtools.md (82%) rename docs/{src/pages => }/graphql.md (82%) rename docs/{src/pages => }/guides/background-fetching-indicators.md (96%) create mode 100644 docs/guides/caching.md create mode 100644 docs/guides/custom-logger.md rename docs/{src/pages => }/guides/default-query-function.md (86%) rename docs/{src/pages => }/guides/dependent-queries.md (57%) create mode 100644 docs/guides/disabling-queries.md rename docs/{src/pages => }/guides/does-this-replace-client-state.md (100%) rename docs/{src/pages => }/guides/filters.md (76%) rename docs/{src/pages => }/guides/important-defaults.md (100%) rename docs/{src/pages => }/guides/infinite-queries.md (94%) rename docs/{src/pages => }/guides/initial-query-data.md (91%) rename docs/{src/pages => }/guides/invalidations-from-mutations.md (87%) rename docs/{src/pages => }/guides/migrating-to-react-query-3.md (97%) create mode 100644 docs/guides/migrating-to-react-query-4.md rename docs/{src/pages => }/guides/mutations.md (77%) create mode 100644 docs/guides/network-mode.md rename docs/{src/pages => }/guides/optimistic-updates.md (90%) rename docs/{src/pages => }/guides/paginated-queries.md (100%) rename docs/{src/pages => }/guides/parallel-queries.md (77%) rename docs/{src/pages => }/guides/placeholder-query-data.md (93%) rename docs/{src/pages => }/guides/prefetching.md (92%) rename docs/{src/pages => }/guides/queries.md (63%) rename docs/{src/pages => }/guides/query-cancellation.md (93%) rename docs/{src/pages => }/guides/query-functions.md (73%) rename docs/{src/pages => }/guides/query-invalidation.md (91%) rename docs/{src/pages => }/guides/query-keys.md (73%) rename docs/{src/pages => }/guides/query-retries.md (90%) rename docs/{src/pages => }/guides/scroll-restoration.md (100%) rename docs/{src/pages => }/guides/ssr.md (90%) rename docs/{src/pages => }/guides/suspense.md (94%) rename docs/{src/pages => }/guides/testing.md (88%) rename docs/{src/pages => }/guides/updates-from-mutation-responses.md (100%) rename docs/{src/pages => }/guides/window-focus-refetching.md (93%) rename docs/{src/pages => }/installation.md (57%) delete mode 100644 docs/jsconfig.json delete mode 100644 docs/next.config.js rename docs/{src/pages => }/overview.md (96%) delete mode 100644 docs/package.json rename docs/{src/pages => }/plugins/broadcastQueryClient.md (100%) rename docs/{src/pages/plugins/createAsyncStoragePersistor.md => plugins/createAsyncStoragePersister.md} (59%) create mode 100644 docs/plugins/createSyncStoragePersister.md create mode 100644 docs/plugins/persistQueryClient.md delete mode 100644 docs/postcss.config.js delete mode 100644 docs/public/images/bytes-logo.png delete mode 100644 docs/public/robots.txt rename docs/{src/pages => }/quick-start.md (91%) rename docs/{src/pages => }/react-native.md (93%) rename docs/{src/pages => }/reference/InfiniteQueryObserver.md (96%) rename docs/{src/pages => }/reference/MutationCache.md (92%) rename docs/{src/pages => }/reference/QueriesObserver.md (100%) rename docs/{src/pages => }/reference/QueryCache.md (98%) rename docs/{src/pages => }/reference/QueryClient.md (80%) rename docs/{src/pages => }/reference/QueryClientProvider.md (59%) rename docs/{src/pages => }/reference/QueryErrorResetBoundary.md (92%) rename docs/{src/pages => }/reference/QueryObserver.md (83%) rename docs/{src/pages => }/reference/focusManager.md (93%) rename docs/{src/pages => }/reference/hydration.md (71%) rename docs/{src/pages => }/reference/onlineManager.md (88%) rename docs/{src/pages => }/reference/useInfiniteQuery.md (94%) rename docs/{src/pages => }/reference/useIsFetching.md (78%) rename docs/{src/pages => }/reference/useIsMutating.md (76%) rename docs/{src/pages => }/reference/useMutation.md (85%) create mode 100644 docs/reference/useQueries.md rename docs/{src/pages => }/reference/useQuery.md (85%) rename docs/{src/pages => }/reference/useQueryClient.md (75%) rename docs/{src/pages => }/reference/useQueryErrorResetBoundary.md (90%) delete mode 100644 docs/src/components/ArrowRight.js delete mode 100644 docs/src/components/Banner.js delete mode 100644 docs/src/components/BytesForm.js delete mode 100644 docs/src/components/CarbonAds.js delete mode 100644 docs/src/components/CodeBlock.js delete mode 100644 docs/src/components/Container.js delete mode 100644 docs/src/components/DocsPageFooter.js delete mode 100644 docs/src/components/ExternalLink.js delete mode 100644 docs/src/components/Footer.js delete mode 100644 docs/src/components/Highlight.js delete mode 100644 docs/src/components/Highlight2.js delete mode 100644 docs/src/components/LayoutDocs.js delete mode 100644 docs/src/components/LazyImage.js delete mode 100644 docs/src/components/Logo.js delete mode 100644 docs/src/components/MDXComponents.js delete mode 100644 docs/src/components/Markdown.js delete mode 100644 docs/src/components/Nav.js delete mode 100644 docs/src/components/PPPBanner.js delete mode 100644 docs/src/components/ProgressiveImage.js delete mode 100644 docs/src/components/Search.js delete mode 100644 docs/src/components/Seo.js delete mode 100644 docs/src/components/Sidebar.js delete mode 100644 docs/src/components/SidebarCategory.js delete mode 100644 docs/src/components/SidebarHeading.js delete mode 100644 docs/src/components/SidebarMobile.js delete mode 100644 docs/src/components/SidebarNavLink.js delete mode 100644 docs/src/components/SidebarPost.js delete mode 100644 docs/src/components/Sticky.js delete mode 100644 docs/src/components/TWButton.js delete mode 100644 docs/src/components/Toc.js delete mode 100644 docs/src/components/Toc.module.css delete mode 100644 docs/src/components/TocNotion.js delete mode 100644 docs/src/components/blog-markdown.module.css delete mode 100644 docs/src/components/blog/ExternalLink.js delete mode 100644 docs/src/components/blog/Heading.js delete mode 100644 docs/src/components/blog/Image.js delete mode 100644 docs/src/components/blog/dynamic.js delete mode 100644 docs/src/components/blog/intersection-observer/index.js delete mode 100644 docs/src/components/blog/intersection-observer/intersection-observer.js delete mode 100644 docs/src/components/blog/intersection-observer/manager.js delete mode 100644 docs/src/components/blog/intersection-observer/utils.js delete mode 100644 docs/src/components/clients/Client.js delete mode 100644 docs/src/components/clients/ClientsMarquee.js delete mode 100644 docs/src/components/clients/Filters.js delete mode 100644 docs/src/components/forwardRefWithAs.js delete mode 100644 docs/src/components/markdown.module.css delete mode 100644 docs/src/components/useBytesSubmit.js delete mode 100644 docs/src/components/useClipboard.js delete mode 100644 docs/src/components/useIsMobile.js delete mode 100644 docs/src/components/useLocalStorage.js delete mode 100644 docs/src/components/useOverScroll.js delete mode 100644 docs/src/components/useSearch.js delete mode 100644 docs/src/components/useTocHighlight.js delete mode 100644 docs/src/components/utils/throttle.js delete mode 100644 docs/src/images/emblem-light.svg delete mode 100644 docs/src/images/favicon.png delete mode 100644 docs/src/images/logo.svg delete mode 100644 docs/src/images/logos/walmart.svg delete mode 100644 docs/src/images/react-query-og.png delete mode 100644 docs/src/images/react-query-twitter.png delete mode 100644 docs/src/lib/docs/findRouteByPath.js delete mode 100644 docs/src/lib/docs/md-loader.js delete mode 100644 docs/src/lib/docs/remark-paragraph-alerts.js delete mode 100644 docs/src/lib/docs/utils.js delete mode 100644 docs/src/lib/fs-utils.js delete mode 100644 docs/src/lib/get-route-context.js delete mode 100644 docs/src/manifests/getManifest.js delete mode 100644 docs/src/manifests/manifest.json delete mode 100644 docs/src/pages/404.js delete mode 100644 docs/src/pages/_app.js delete mode 100644 docs/src/pages/_document.js delete mode 100644 docs/src/pages/examples/auto-refetching.mdx delete mode 100644 docs/src/pages/examples/basic-graphql-request.mdx delete mode 100644 docs/src/pages/examples/basic.mdx delete mode 100644 docs/src/pages/examples/custom-hooks.mdx delete mode 100644 docs/src/pages/examples/default-query-function.mdx delete mode 100644 docs/src/pages/examples/focus-refetching.mdx delete mode 100644 docs/src/pages/examples/load-more-infinite-scroll.mdx delete mode 100644 docs/src/pages/examples/nextjs.mdx delete mode 100644 docs/src/pages/examples/optimistic-updates-typescript.mdx delete mode 100644 docs/src/pages/examples/optimistic-updates.mdx delete mode 100644 docs/src/pages/examples/pagination.mdx delete mode 100644 docs/src/pages/examples/playground.mdx delete mode 100644 docs/src/pages/examples/prefetching.mdx delete mode 100644 docs/src/pages/examples/react-native.mdx delete mode 100644 docs/src/pages/examples/rick-morty.mdx delete mode 100644 docs/src/pages/examples/simple.mdx delete mode 100644 docs/src/pages/examples/star-wars.mdx delete mode 100644 docs/src/pages/examples/suspense.mdx delete mode 100644 docs/src/pages/guides/caching.md delete mode 100644 docs/src/pages/guides/disabling-queries.md delete mode 100644 docs/src/pages/index.js delete mode 100644 docs/src/pages/plugins/createWebStoragePersistor.md delete mode 100644 docs/src/pages/plugins/persistQueryClient.md delete mode 100644 docs/src/pages/reference/setLogger.md delete mode 100644 docs/src/pages/reference/useQueries.md delete mode 100644 docs/src/pages/typescript.md delete mode 100644 docs/src/siteConfig.js delete mode 100644 docs/src/styles/blog.module.css delete mode 100644 docs/src/styles/index.css delete mode 100644 docs/src/styles/post.module.css delete mode 100644 docs/src/styles/shared.module.css delete mode 100644 docs/src/users.js delete mode 100644 docs/tailwind.config.js create mode 100644 docs/typescript.md rename docs/{src/pages/videos.mdx => videos.md} (100%) delete mode 100644 docs/yarn.lock delete mode 100644 examples/auto-refetching/README.md delete mode 100644 examples/basic-typescript/README.md delete mode 100644 examples/basic/README.md delete mode 100644 examples/default-query-function/README.md delete mode 100644 examples/focus-refetching/README.md delete mode 100644 examples/load-more-infinite-scroll/README.md delete mode 100644 examples/optimistic-updates-typescript/README.md delete mode 100644 examples/optimistic-updates/README.md delete mode 100644 examples/pagination/README.md delete mode 100644 examples/playground/README.md delete mode 100644 examples/prefetching/README.md delete mode 100644 examples/prefetching/package.json rename examples/{ => react}/auto-refetching/.gitignore (100%) create mode 100644 examples/react/auto-refetching/README.md rename examples/{ => react}/auto-refetching/next.config.js (100%) rename examples/{ => react}/auto-refetching/package.json (73%) rename examples/{ => react}/auto-refetching/pages/api/data.js (100%) rename examples/{ => react}/auto-refetching/pages/index.js (82%) rename examples/{ => react}/basic-graphql-request/.babelrc (100%) rename examples/{ => react}/basic-graphql-request/.eslintrc (100%) rename examples/{ => react}/basic-graphql-request/.gitignore (100%) rename examples/{ => react}/basic-graphql-request/.prettierrc (100%) rename examples/{ => react}/basic-graphql-request/.rescriptsrc.js (100%) create mode 100644 examples/react/basic-graphql-request/README.md create mode 100644 examples/react/basic-graphql-request/package.json rename examples/{ => react}/basic-graphql-request/public/favicon.ico (100%) rename examples/{ => react}/basic-graphql-request/public/index.html (100%) rename examples/{ => react}/basic-graphql-request/public/manifest.json (100%) rename examples/{ => react}/basic-graphql-request/src/index.js (93%) rename examples/{ => react}/basic-typescript/.babelrc (100%) rename examples/{ => react}/basic-typescript/.eslintrc (100%) rename examples/{ => react}/basic-typescript/.gitignore (100%) rename examples/{ => react}/basic-typescript/.prettierrc (100%) rename examples/{ => react}/basic-typescript/.rescriptsrc.js (100%) create mode 100644 examples/react/basic-typescript/README.md rename examples/{ => react}/basic-typescript/package.json (82%) rename examples/{ => react}/basic-typescript/public/favicon.ico (100%) rename examples/{ => react}/basic-typescript/public/index.html (100%) rename examples/{ => react}/basic-typescript/public/manifest.json (100%) rename examples/{ => react}/basic-typescript/src/index.tsx (77%) rename examples/{ => react}/basic-typescript/tsconfig.json (100%) rename examples/{ => react}/basic/.babelrc (100%) rename examples/{ => react}/basic/.eslintrc (100%) rename examples/{ => react}/basic/.gitignore (100%) rename examples/{ => react}/basic/.prettierrc (100%) rename examples/{ => react}/basic/.rescriptsrc.js (100%) create mode 100644 examples/react/basic/README.md rename examples/{ => react}/basic/package.json (83%) rename examples/{ => react}/basic/public/favicon.ico (100%) rename examples/{ => react}/basic/public/index.html (100%) rename examples/{ => react}/basic/public/manifest.json (100%) rename examples/{ => react}/basic/src/index.js (93%) rename examples/{ => react}/custom-hooks/.babelrc (100%) rename examples/{ => react}/custom-hooks/.eslintrc (100%) rename examples/{ => react}/custom-hooks/.gitignore (100%) rename examples/{ => react}/custom-hooks/.prettierrc (100%) rename examples/{ => react}/custom-hooks/.rescriptsrc.js (100%) rename examples/{ => react}/custom-hooks/README.md (70%) rename examples/{ => react}/custom-hooks/package.json (80%) rename examples/{ => react}/custom-hooks/public/favicon.ico (100%) rename examples/{ => react}/custom-hooks/public/index.html (100%) rename examples/{ => react}/custom-hooks/public/manifest.json (100%) rename examples/{ => react}/custom-hooks/src/hooks/usePost.js (85%) rename examples/{ => react}/custom-hooks/src/hooks/usePosts.js (69%) rename examples/{ => react}/custom-hooks/src/index.js (93%) rename examples/{ => react}/default-query-function/.babelrc (100%) rename examples/{ => react}/default-query-function/.eslintrc (100%) rename examples/{ => react}/default-query-function/.gitignore (100%) rename examples/{ => react}/default-query-function/.prettierrc (100%) rename examples/{ => react}/default-query-function/.rescriptsrc.js (100%) create mode 100644 examples/react/default-query-function/README.md rename examples/{playground => react/default-query-function}/package.json (78%) rename examples/{ => react}/default-query-function/public/favicon.ico (100%) rename examples/{ => react}/default-query-function/public/index.html (100%) rename examples/{ => react}/default-query-function/public/manifest.json (100%) rename examples/{ => react}/default-query-function/src/index.js (90%) rename examples/{ => react}/focus-refetching/.gitignore (100%) create mode 100644 examples/react/focus-refetching/README.md rename examples/{ => react}/focus-refetching/next.config.js (100%) create mode 100644 examples/react/focus-refetching/package.json rename examples/{ => react}/focus-refetching/pages/api/user.js (100%) rename examples/{ => react}/focus-refetching/pages/index.js (86%) rename examples/{ => react}/load-more-infinite-scroll/.gitignore (100%) create mode 100644 examples/react/load-more-infinite-scroll/README.md rename examples/{ => react}/load-more-infinite-scroll/next.config.js (100%) rename examples/{ => react}/load-more-infinite-scroll/package.json (74%) rename examples/{ => react}/load-more-infinite-scroll/pages/about.js (100%) rename examples/{ => react}/load-more-infinite-scroll/pages/api/projects.js (100%) rename examples/{ => react}/load-more-infinite-scroll/pages/index.js (86%) rename examples/{ => react}/nextjs/.gitignore (100%) rename examples/{ => react}/nextjs/README.md (87%) rename examples/{ => react}/nextjs/components/Header/index.js (100%) rename examples/{ => react}/nextjs/components/InfoBox/index.js (100%) rename examples/{ => react}/nextjs/components/Layout/index.js (100%) rename examples/{ => react}/nextjs/components/PostList/index.js (100%) rename examples/{ => react}/nextjs/components/index.js (100%) rename examples/{ => react}/nextjs/hooks/index.js (100%) rename examples/{ => react}/nextjs/hooks/usePosts/index.js (67%) rename examples/{ => react}/nextjs/next.config.js (100%) rename examples/{ => react}/nextjs/package.json (67%) rename examples/{ => react}/nextjs/pages/_app.js (70%) rename examples/{ => react}/nextjs/pages/client-only.js (100%) rename examples/{ => react}/nextjs/pages/index.js (90%) rename examples/{ => react}/nextjs/yarn.lock (100%) rename examples/{suspense => react/offline}/.babelrc (100%) rename examples/{playground => react/offline}/.eslintrc (100%) rename examples/{optimistic-updates-typescript => react/offline}/.gitignore (100%) rename examples/{rick-morty => react/offline}/.prettierrc (100%) rename examples/{playground => react/offline}/.rescriptsrc.js (100%) create mode 100644 examples/react/offline/README.md create mode 100644 examples/react/offline/package.json rename examples/{simple => react/offline}/public/favicon.ico (100%) rename examples/{playground => react/offline}/public/index.html (100%) rename examples/{playground => react/offline}/public/manifest.json (100%) create mode 100644 examples/react/offline/public/mockServiceWorker.js create mode 100644 examples/react/offline/src/App.js create mode 100644 examples/react/offline/src/api.js create mode 100644 examples/react/offline/src/index.js create mode 100644 examples/react/offline/src/movies.js rename examples/{optimistic-updates => react/optimistic-updates-typescript}/.gitignore (100%) create mode 100644 examples/react/optimistic-updates-typescript/README.md rename examples/{ => react}/optimistic-updates-typescript/next-env.d.ts (100%) rename examples/{ => react}/optimistic-updates-typescript/next.config.js (100%) rename examples/{ => react}/optimistic-updates-typescript/package.json (75%) rename examples/{ => react}/optimistic-updates-typescript/pages/api/data.js (100%) rename examples/{ => react}/optimistic-updates-typescript/pages/index.tsx (69%) rename examples/{ => react}/optimistic-updates-typescript/tsconfig.json (100%) rename examples/{pagination => react/optimistic-updates}/.gitignore (100%) create mode 100644 examples/react/optimistic-updates/README.md rename examples/{ => react}/optimistic-updates/next.config.js (100%) rename examples/{ => react}/optimistic-updates/package.json (73%) rename examples/{ => react}/optimistic-updates/pages/api/data.js (100%) rename examples/{ => react}/optimistic-updates/pages/index.js (76%) rename examples/{playground => react/pagination}/.gitignore (100%) create mode 100644 examples/react/pagination/README.md rename examples/{ => react}/pagination/next.config.js (100%) rename examples/{ => react}/pagination/package.json (74%) rename examples/{ => react}/pagination/pages/api/projects.js (100%) rename examples/{ => react}/pagination/pages/index.js (87%) rename examples/{ => react}/playground/.babelrc (100%) rename examples/{rick-morty => react/playground}/.eslintrc (100%) rename examples/{prefetching => react/playground}/.gitignore (100%) rename examples/{ => react}/playground/.prettierrc (100%) rename examples/{rick-morty => react/playground}/.rescriptsrc.js (100%) create mode 100644 examples/react/playground/README.md rename examples/{default-query-function => react/playground}/package.json (81%) rename examples/{ => react}/playground/public/favicon.ico (100%) rename examples/{simple => react/playground}/public/index.html (100%) rename examples/{rick-morty => react/playground}/public/manifest.json (100%) rename examples/{ => react}/playground/src/index.js (94%) rename examples/{ => react}/playground/src/styles.css (100%) rename examples/{rick-morty => react/prefetching}/.gitignore (100%) create mode 100644 examples/react/prefetching/README.md rename examples/{ => react}/prefetching/libs/fetch.js (100%) rename examples/{ => react}/prefetching/next.config.js (100%) rename examples/{focus-refetching => react/prefetching}/package.json (74%) rename examples/{ => react}/prefetching/pages/[user]/[repo].js (83%) rename examples/{ => react}/prefetching/pages/api/data.js (100%) rename examples/{ => react}/prefetching/pages/index.js (83%) rename examples/{ => react}/react-native/.eslintrc (100%) rename examples/{ => react}/react-native/.gitignore (100%) rename examples/{ => react}/react-native/.prettierrc (100%) rename examples/{ => react}/react-native/App.tsx (90%) rename examples/{ => react}/react-native/README.md (100%) rename examples/{ => react}/react-native/app.json (100%) rename examples/{ => react}/react-native/assets/adaptive-icon.png (100%) rename examples/{ => react}/react-native/assets/favicon.png (100%) rename examples/{ => react}/react-native/assets/icon.png (100%) rename examples/{ => react}/react-native/assets/splash.png (100%) rename examples/{ => react}/react-native/babel.config.js (100%) rename examples/{ => react}/react-native/package.json (91%) rename examples/{ => react}/react-native/src/components/Divider.tsx (89%) rename examples/{ => react}/react-native/src/components/ErrorMessage.tsx (91%) rename examples/{ => react}/react-native/src/components/ListItem.tsx (96%) rename examples/{ => react}/react-native/src/components/LoadingIndicator.tsx (91%) rename examples/{ => react}/react-native/src/data/movies.json (100%) rename examples/{ => react}/react-native/src/hooks/useAppState.ts (100%) rename examples/{ => react}/react-native/src/hooks/useOnlineManager.ts (85%) rename examples/{ => react}/react-native/src/hooks/useRefreshByUser.ts (92%) rename examples/{ => react}/react-native/src/hooks/useRefreshOnFocus.ts (91%) rename examples/{ => react}/react-native/src/lib/api.ts (100%) rename examples/{ => react}/react-native/src/navigation/MoviesStack.tsx (95%) rename examples/{ => react}/react-native/src/navigation/types.ts (100%) rename examples/{ => react}/react-native/src/screens/MovieDetailsScreen.tsx (97%) rename examples/{ => react}/react-native/src/screens/MoviesListScreen.tsx (95%) rename examples/{ => react}/react-native/tsconfig.json (100%) rename examples/{ => react}/react-native/yarn.lock (100%) rename examples/{ => react}/rick-morty/.babelrc (100%) rename examples/{simple => react/rick-morty}/.eslintrc (100%) rename examples/{simple => react/rick-morty}/.gitignore (100%) rename examples/{simple => react/rick-morty}/.prettierrc (100%) rename examples/{simple => react/rick-morty}/.rescriptsrc.js (100%) create mode 100644 examples/react/rick-morty/README.md rename examples/{ => react}/rick-morty/package.json (83%) rename examples/{ => react}/rick-morty/public/favicon.ico (100%) rename examples/{ => react}/rick-morty/public/index.html (100%) rename examples/{simple => react/rick-morty}/public/manifest.json (100%) rename examples/{star-wars => react/rick-morty}/src/App.js (87%) rename examples/{ => react}/rick-morty/src/Character.js (92%) rename examples/{ => react}/rick-morty/src/Characters.js (89%) rename examples/{ => react}/rick-morty/src/Episode.js (88%) rename examples/{ => react}/rick-morty/src/Episodes.js (88%) rename examples/{ => react}/rick-morty/src/Home.js (100%) rename examples/{ => react}/rick-morty/src/Layout.js (100%) rename examples/{ => react}/rick-morty/src/fetch.js (100%) rename examples/{star-wars => react/rick-morty}/src/index.js (54%) rename examples/{ => react}/rick-morty/src/styles.css (100%) rename examples/{ => react}/simple/.babelrc (100%) rename examples/{star-wars => react/simple}/.eslintrc (100%) rename examples/{star-wars => react/simple}/.gitignore (100%) rename examples/{star-wars => react/simple}/.prettierrc (100%) rename examples/{star-wars => react/simple}/.rescriptsrc.js (100%) create mode 100644 examples/react/simple/README.md rename examples/{basic-graphql-request => react/simple}/package.json (79%) create mode 100644 examples/react/simple/public/favicon.ico create mode 100644 examples/react/simple/public/index.html rename examples/{star-wars => react/simple}/public/manifest.json (100%) rename examples/{ => react}/simple/src/index.js (65%) rename examples/{ => react}/star-wars/.babelrc (100%) rename examples/{suspense => react/star-wars}/.eslintrc (100%) rename examples/{suspense => react/star-wars}/.gitignore (100%) create mode 100644 examples/react/star-wars/.prettierrc rename examples/{suspense => react/star-wars}/.rescriptsrc.js (100%) create mode 100644 examples/react/star-wars/README.md rename examples/{ => react}/star-wars/package.json (81%) rename examples/{ => react}/star-wars/public/favicon.ico (100%) rename examples/{ => react}/star-wars/public/index.html (100%) rename examples/{suspense => react/star-wars}/public/manifest.json (100%) rename examples/{rick-morty => react/star-wars}/src/App.js (87%) rename examples/{ => react}/star-wars/src/Character.js (92%) rename examples/{ => react}/star-wars/src/Characters.js (88%) rename examples/{ => react}/star-wars/src/Film.js (88%) rename examples/{ => react}/star-wars/src/Films.js (90%) rename examples/{ => react}/star-wars/src/Home.js (100%) rename examples/{ => react}/star-wars/src/Layout.js (100%) rename examples/{ => react}/star-wars/src/fetch.js (100%) rename examples/{rick-morty => react/star-wars}/src/index.js (54%) rename examples/{ => react}/star-wars/src/styles.css (100%) create mode 100644 examples/react/suspense/.babelrc create mode 100644 examples/react/suspense/.eslintrc create mode 100644 examples/react/suspense/.gitignore rename examples/{ => react}/suspense/.prettierrc (100%) create mode 100644 examples/react/suspense/.rescriptsrc.js rename examples/{basic-graphql-request => react/suspense}/README.md (100%) rename examples/{ => react}/suspense/package.json (80%) rename examples/{ => react}/suspense/public/favicon.ico (100%) rename examples/{ => react}/suspense/public/index.html (100%) create mode 100644 examples/react/suspense/public/manifest.json rename examples/{ => react}/suspense/src/components/Button.js (81%) rename examples/{ => react}/suspense/src/components/Project.js (93%) rename examples/{ => react}/suspense/src/components/Projects.js (85%) rename examples/{ => react}/suspense/src/components/Spinner.js (100%) rename examples/{ => react}/suspense/src/index.js (91%) rename examples/{ => react}/suspense/src/queries.js (100%) rename examples/{ => react}/suspense/src/styles.css (100%) delete mode 100644 examples/rick-morty/README.md delete mode 100644 examples/simple/README.md delete mode 100644 examples/simple/package.json delete mode 100644 examples/star-wars/README.md delete mode 100644 examples/suspense/README.md delete mode 100644 hydration/package.json delete mode 100644 jest.config.js create mode 100644 jest.config.ts create mode 100644 lerna.json create mode 100644 media/repo-header.png create mode 100644 old/rollup.config.js create mode 100644 package-lock.json create mode 100644 packages/query-async-storage-persister/.eslintrc create mode 100644 packages/query-async-storage-persister/package.json create mode 100644 packages/query-async-storage-persister/src/__tests__/asyncThrottle.test.ts create mode 100644 packages/query-async-storage-persister/src/asyncThrottle.ts create mode 100644 packages/query-async-storage-persister/src/index.ts create mode 100644 packages/query-async-storage-persister/tsconfig.json create mode 100644 packages/query-broadcast-client-experimental/.eslintrc create mode 100644 packages/query-broadcast-client-experimental/package.json rename {src/broadcastQueryClient-experimental => packages/query-broadcast-client-experimental/src}/index.ts (71%) create mode 100644 packages/query-broadcast-client-experimental/tsconfig.json create mode 100644 packages/query-broadcast-client-experimental/yarn.lock create mode 100644 packages/query-core/.eslintrc create mode 100644 packages/query-core/package.json rename {src/core => packages/query-core/src}/focusManager.ts (81%) rename {src/core => packages/query-core/src}/hydration.ts (87%) rename {src/core => packages/query-core/src}/index.ts (82%) rename {src/core => packages/query-core/src}/infiniteQueryBehavior.ts (82%) rename {src/core => packages/query-core/src}/infiniteQueryObserver.ts (63%) create mode 100644 packages/query-core/src/logger.native.ts create mode 100644 packages/query-core/src/logger.ts create mode 100644 packages/query-core/src/mutation.ts rename {src/core => packages/query-core/src}/mutationCache.ts (55%) rename {src/core => packages/query-core/src}/mutationObserver.ts (94%) create mode 100644 packages/query-core/src/notifyManager.ts rename {src/core => packages/query-core/src}/onlineManager.ts (84%) rename {src/core => packages/query-core/src}/queriesObserver.ts (68%) rename {src/core => packages/query-core/src}/query.ts (54%) rename {src/core => packages/query-core/src}/queryCache.ts (81%) rename {src/core => packages/query-core/src}/queryClient.ts (66%) rename {src/core => packages/query-core/src}/queryObserver.ts (74%) create mode 100644 packages/query-core/src/removable.ts create mode 100644 packages/query-core/src/retryer.ts rename {src/core => packages/query-core/src}/subscribable.ts (67%) rename {src/core => packages/query-core/src}/tests/focusManager.test.tsx (86%) rename {src/core => packages/query-core/src}/tests/hydration.test.tsx (58%) rename {src/core => packages/query-core/src}/tests/infiniteQueryBehavior.test.tsx (85%) rename {src/core => packages/query-core/src}/tests/infiniteQueryObserver.test.tsx (75%) create mode 100644 packages/query-core/src/tests/mutationCache.test.tsx rename {src/core => packages/query-core/src}/tests/mutationObserver.test.tsx (92%) rename {src/core => packages/query-core/src}/tests/mutations.test.tsx (78%) rename {src/core => packages/query-core/src}/tests/notifyManager.test.tsx (65%) rename {src/core => packages/query-core/src}/tests/onlineManager.test.tsx (86%) rename {src/core => packages/query-core/src}/tests/queriesObserver.test.tsx (72%) rename {src/core => packages/query-core/src}/tests/query.test.tsx (83%) rename {src/core => packages/query-core/src}/tests/queryCache.test.tsx (76%) rename {src/core => packages/query-core/src}/tests/queryClient.test.tsx (63%) rename {src/core => packages/query-core/src}/tests/queryObserver.test.tsx (85%) rename {src/core => packages/query-core/src}/tests/utils.test.tsx (82%) rename {src/core => packages/query-core/src}/types.ts (85%) rename {src/core => packages/query-core/src}/utils.ts (73%) create mode 100644 packages/query-core/tsconfig.json create mode 100644 packages/query-sync-storage-persister/.eslintrc create mode 100644 packages/query-sync-storage-persister/package.json create mode 100644 packages/query-sync-storage-persister/src/__tests__/storageIsFull.test.ts create mode 100644 packages/query-sync-storage-persister/src/index.ts create mode 100644 packages/query-sync-storage-persister/tsconfig.json create mode 100644 packages/react-query-devtools/.eslintrc create mode 100644 packages/react-query-devtools/package.json rename {src/devtools => packages/react-query-devtools/src}/Explorer.tsx (93%) rename {src/devtools => packages/react-query-devtools/src}/Logo.tsx (100%) rename {src/devtools/tests => packages/react-query-devtools/src/__tests__}/Explorer.test.tsx (97%) create mode 100644 packages/react-query-devtools/src/__tests__/devtools.test.tsx rename {src/devtools/tests => packages/react-query-devtools/src/__tests__}/utils.tsx (55%) rename {src/devtools => packages/react-query-devtools/src}/devtools.tsx (50%) rename {src/devtools => packages/react-query-devtools/src}/index.ts (100%) create mode 100644 packages/react-query-devtools/src/noop.ts rename {src/devtools => packages/react-query-devtools/src}/styledComponents.ts (99%) rename {src/devtools => packages/react-query-devtools/src}/theme.tsx (92%) rename {src/devtools => packages/react-query-devtools/src}/useLocalStorage.ts (88%) rename {src/devtools => packages/react-query-devtools/src}/useMediaQuery.ts (83%) rename {src/devtools => packages/react-query-devtools/src}/utils.ts (69%) create mode 100644 packages/react-query-devtools/tsconfig.json create mode 100644 packages/react-query-persist-client/.eslintrc create mode 100644 packages/react-query-persist-client/package.json create mode 100644 packages/react-query-persist-client/src/PersistQueryClientProvider.tsx create mode 100644 packages/react-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx create mode 100644 packages/react-query-persist-client/src/__tests__/persist.test.tsx create mode 100644 packages/react-query-persist-client/src/index.ts create mode 100644 packages/react-query-persist-client/src/persist.ts create mode 100644 packages/react-query-persist-client/src/retryStrategies.ts create mode 100644 packages/react-query-persist-client/tsconfig.json create mode 100644 packages/react-query/.eslintrc create mode 100644 packages/react-query/__tests__/jest.setup.js create mode 100644 packages/react-query/codemods/jest.config.js create mode 100644 packages/react-query/codemods/v4/__testfixtures__/default-import.input.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/default-import.output.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/named-import.input.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/named-import.output.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/namespaced-import.input.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/namespaced-import.output.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/parameter-is-identifier.input.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/parameter-is-identifier.output.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/parameter-is-object-expression.input.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/parameter-is-object-expression.output.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/replace-import-specifier.input.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/replace-import-specifier.output.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/type-arguments.input.tsx create mode 100644 packages/react-query/codemods/v4/__testfixtures__/type-arguments.output.tsx create mode 100644 packages/react-query/codemods/v4/__tests__/key-transformation.test.js create mode 100644 packages/react-query/codemods/v4/__tests__/replace-import-specifier.test.js create mode 100644 packages/react-query/codemods/v4/key-transformation.js create mode 100644 packages/react-query/codemods/v4/replace-import-specifier.js create mode 100644 packages/react-query/codemods/v4/utils/index.js create mode 100644 packages/react-query/codemods/v4/utils/replacers/key-replacer.js create mode 100644 packages/react-query/codemods/v4/utils/transformers/query-cache-transformer.js create mode 100644 packages/react-query/codemods/v4/utils/transformers/query-client-transformer.js create mode 100644 packages/react-query/codemods/v4/utils/transformers/use-query-like-transformer.js create mode 100644 packages/react-query/codemods/v4/utils/unprocessable-key-error.js create mode 100644 packages/react-query/package.json rename {src/react => packages/react-query/src}/Hydrate.tsx (72%) rename {src/react => packages/react-query/src}/QueryClientProvider.tsx (51%) rename {src/react => packages/react-query/src}/QueryErrorResetBoundary.tsx (92%) rename {src/react/tests => packages/react-query/src/__tests__}/Hydrate.test.tsx (56%) rename {src/react/tests => packages/react-query/src/__tests__}/QueryClientProvider.test.tsx (64%) rename {src/react/tests => packages/react-query/src/__tests__}/QueryResetErrorBoundary.test.tsx (89%) rename {src/react/tests => packages/react-query/src/__tests__}/ssr-hydration.test.tsx (60%) rename {src/react/tests => packages/react-query/src/__tests__}/ssr.test.tsx (77%) rename {src/react/tests => packages/react-query/src/__tests__}/suspense.test.tsx (85%) rename {src/react/tests => packages/react-query/src/__tests__}/useInfiniteQuery.test.tsx (80%) create mode 100644 packages/react-query/src/__tests__/useIsFetching.test.tsx create mode 100644 packages/react-query/src/__tests__/useIsMutating.test.tsx create mode 100644 packages/react-query/src/__tests__/useMutation.test.tsx create mode 100644 packages/react-query/src/__tests__/useQueries.test.tsx rename {src/react/tests => packages/react-query/src/__tests__}/useQuery.test.tsx (69%) create mode 100644 packages/react-query/src/__tests__/useQuery.types.test.tsx create mode 100644 packages/react-query/src/__tests__/utils.tsx rename {src/react => packages/react-query/src}/index.ts (69%) create mode 100644 packages/react-query/src/isRestoring.tsx rename {src/react => packages/react-query/src}/reactBatchedUpdates.native.ts (100%) rename {src/react => packages/react-query/src}/reactBatchedUpdates.ts (65%) rename {src/react => packages/react-query/src}/setBatchUpdatesFn.ts (70%) rename {src/react => packages/react-query/src}/types.ts (63%) rename {src/react => packages/react-query/src}/useBaseQuery.ts (59%) rename {src/react => packages/react-query/src}/useInfiniteQuery.ts (80%) create mode 100644 packages/react-query/src/useIsFetching.ts create mode 100644 packages/react-query/src/useIsMutating.ts rename {src/react => packages/react-query/src}/useMutation.ts (57%) rename {src/react => packages/react-query/src}/useQueries.ts (63%) create mode 100644 packages/react-query/src/useQuery.ts rename {src/react => packages/react-query/src}/utils.ts (53%) create mode 100644 packages/react-query/tsconfig.json delete mode 100644 persistQueryClient-experimental/package.json delete mode 100644 prettier.config.js delete mode 100644 react/package.json create mode 100644 rollup.config.ts create mode 100644 scripts/config.ts create mode 100644 scripts/fix-package-json.js create mode 100644 scripts/publish.ts create mode 100644 scripts/tsconfig.json create mode 100644 scripts/types.ts delete mode 100644 src/core/logger.ts delete mode 100644 src/core/mutation.ts delete mode 100644 src/core/notifyManager.ts delete mode 100644 src/core/retryer.ts delete mode 100644 src/core/tests/mutationCache.test.tsx delete mode 100644 src/createAsyncStoragePersistor-experimental/index.ts delete mode 100644 src/createWebStoragePersistor-experimental/index.ts delete mode 100644 src/createWebStoragePersistor-experimental/tests/storageIsFull.test.ts delete mode 100644 src/devtools/tests/devtools.test.tsx delete mode 100644 src/hydration/index.ts delete mode 100644 src/index.ts delete mode 100644 src/persistQueryClient-experimental/index.ts delete mode 100644 src/react/logger.native.ts delete mode 100644 src/react/logger.ts delete mode 100644 src/react/setLogger.ts delete mode 100644 src/react/tests/logger.native.test.tsx delete mode 100644 src/react/tests/useIsFetching.test.tsx delete mode 100644 src/react/tests/useIsMutating.test.tsx delete mode 100644 src/react/tests/useMutation.test.tsx delete mode 100644 src/react/tests/useQueries.test.tsx delete mode 100644 src/react/tests/utils.tsx delete mode 100644 src/react/useIsFetching.ts delete mode 100644 src/react/useIsMutating.ts delete mode 100644 src/react/useQuery.ts delete mode 100644 src/ts3.8/index.ts delete mode 100644 src/ts3.8/useQueries.ts create mode 100644 tests/utils.ts create mode 100644 tsconfig.base.json delete mode 100644 tsconfig.types.json delete mode 100644 yarn.lock diff --git a/.browserslistrc b/.browserslistrc index 41bcaa1d38..01b924286a 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,9 +1,7 @@ # Browsers we support -> 0.5% Chrome >= 73 -ChromeAndroid >= 75 -Firefox >= 67 -Edge >= 17 -IE 11 -Safari >= 12.1 -iOS >= 11.3 \ No newline at end of file +Firefox >= 78 +Edge >= 79 +Safari >= 12.0 +iOS >= 12.0 +opera >= 53 diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json index e9f693a51f..483392af19 100644 --- a/.codesandbox/ci.json +++ b/.codesandbox/ci.json @@ -1,5 +1,6 @@ { - "packages": ["./"], - "sandboxes": ["/examples/basic", "/examples/basic-typescript"], - "node": "14" + "installCommand": "install:csb", + "sandboxes": ["/examples/react/basic", "/examples/react/basic-typescript"], + "packages": ["packages/**"], + "node": "16" } diff --git a/.eslintrc b/.eslintrc index 832b08a87c..e5470987da 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,5 @@ { + "root": true, "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint", "import"], "extends": [ @@ -12,8 +13,23 @@ "es6": true }, "parserOptions": { + "project": "./tsconfig.base.json", "sourceType": "module" }, + "settings": { + "import/parsers": { + "@typescript-eslint/parser": [".ts", ".tsx"] + }, + "import/resolver": { + "node": true, + "typescript": { + "project": "packages/*/tsconfig.json" + } + }, + "react": { + "version": "detect" + } + }, "rules": { "react/jsx-key": ["error", { "checkFragmentShorthand": true }], "@typescript-eslint/ban-types": "off", @@ -22,6 +38,7 @@ "@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/no-unnecessary-condition": "error", "@typescript-eslint/no-inferrable-types": [ "error", { @@ -30,7 +47,7 @@ ], "no-shadow": "error", "import/no-cycle": "error", - "import/no-unresolved": ["error", { "ignore": ["react-query"] }], + "import/no-unresolved": ["error", { "ignore": ["^@tanstack\/"] }], "import/no-unused-modules": ["off", { "unusedExports": true }], "no-redeclare": "off" } diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/ci-v3.yml similarity index 74% rename from .github/workflows/test-and-publish.yml rename to .github/workflows/ci-v3.yml index bfb40333b2..7e79b080e2 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/ci-v3.yml @@ -3,20 +3,17 @@ name: react-query tests on: push: branches: - - 'main' - - 'next' - - 'beta' - '1.x' - '2.x' - pull_request: - + - '3.x' jobs: test: - name: 'Node ${{ matrix.node }}' + name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}' runs-on: ubuntu-latest strategy: matrix: - node: [12, 14, 16] + node: [14, 16] + react: [17, 18] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -25,8 +22,10 @@ jobs: - name: Install dependencies uses: bahmutov/npm-install@v1 - run: yarn test:ci + env: + REACTJS_VERSION: ${{ matrix.react }} - run: yarn test:size - if: matrix.node == '16' + if: matrix.node == '16' && matrix.react == '18' env: BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} - name: Upload coverage to Codecov @@ -35,8 +34,8 @@ jobs: publish-module: name: 'Publish Module to NPM' needs: test - # publish only when merged in main on original repo, not on PR - if: github.repository == 'TanStack/query' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x') + # publish only when merged in master on original repo, not on PR + if: github.repository == 'TanStack/query' && (github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x' || github.ref == 'refs/heads/3.x') runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..2937d9c0a4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: ci +concurrency: + group: publish-${{ github.github.base_ref }} + cancel-in-progress: true +on: [push] +jobs: + test-and-publish: + if: github.repository == 'TanStack/query' && github.event_name != 'pull_request' + name: 'Test & Publish' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - uses: actions/setup-node@v2 + with: + node-version: 16.14.2 + registry-url: https://registry.npmjs.org/ + cache: 'npm' + - run: | + npm i + npm run test:ci + git config --global user.name 'Tanner Linsley' + git config --global user.email 'tannerlinsley@users.noreply.github.com' + npm run cipublish + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000000..820947817f --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,28 @@ +name: pr +on: [pull_request] +jobs: + test: + name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}' + runs-on: ubuntu-latest + strategy: + matrix: + node: [16.14.2] + react: [17, 18] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - name: Install dependencies + uses: bahmutov/npm-install@v1 + with: + install-command: npm install + - run: npm run test:ci + env: + REACTJS_VERSION: ${{ matrix.react }} + - run: npm run test:size + if: matrix.react == '18' + env: + BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 diff --git a/.gitignore b/.gitignore index f821d4d40a..950bf7c71d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ node_modules # builds types build +*/build dist lib es @@ -30,7 +31,13 @@ yarn-error.log* .history size-plugin.json stats-hydration.json -stats-react.json +stats.json stats.html .vscode/settings.json -.idea/ + +*.log +.DS_Store +node_modules +.cache +dist +.idea diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 7639205ec9..0000000000 --- a/.gitpod.yml +++ /dev/null @@ -1,18 +0,0 @@ -tasks: - - name: Auto Build - init: | - yarn install - gp sync-done boot - command: yarn run start - - - name: Docs - before: cd docs/ - init: | - gp sync-await boot - yarn install - command: yarn dev - openMode: split-right - -ports: - - port: 3000 - onOpen: open-preview diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000000..6276cf12fb --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16.14.2 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..e3b414c7e0 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "all" +} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 420d141d57..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "workbench.colorCustomizations": { - "titleBar.activeBackground": "#00da63", // change this color! - "titleBar.inactiveBackground": "#00da63", // change this color! - "titleBar.activeForeground": "#ffffff", // change this color! - "titleBar.inactiveForeground": "#ffffff" // change this color! - } -} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index d406a0ee7b..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,125 +0,0 @@ -# Contributing - -## Questions - -If you have questions about implementation details, help or support, then please use our dedicated community forum at [GitHub Discussions](https://github.com/tannerlinsley/react-query/discussions) **PLEASE NOTE:** If you choose to instead open an issue for your question, your issue will be immediately closed and redirected to the forum. - -## Reporting Issues - -If you have found what you think is a bug, please [file an issue](https://github.com/tannerlinsley/react-query/issues/new). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues will be immediately closed and redirected to [GitHub Discussions](https://github.com/tannerlinsley/react-query/discussions) - -## Suggesting new features - -If you are here to suggest a feature, first create an issue if it does not already exist. From there, we will discuss use-cases for the feature and then finally discuss how it could be implemented. - -## Development - -If you have been assigned to fix an issue or develop a new feature, please follow these steps to get started: - -- Fork this repository -- Install dependencies by running `$ yarn` -- Link `react-query` locally by running `$ yarn link` -- Auto-build files as you edit by running `$ yarn start` -- Implement your changes and tests to files in the `src/` directory and corresponding test files -- To run examples, follow their individual directions. Usually this is just `$ yarn && yarn start`. -- To run examples using your local build, link to the local `react-query` by running `$ yarn link react-query` from the example's directory -- Document your changes in the appropriate doc page -- Git stage your required changes and commit (see below commit guidelines) -- Submit PR for review - -## Online one-click setup - -You can use Gitpod (An Online Open Source VS Code like IDE which is free for Open Source) for developing online. With a single click it will start a workspace and automatically: - -- clone the `react-query` repo. -- install all the dependencies in `/` and `/docs`. -- run `yarn start` in the root(`/`) to Auto-build files. -- run `yarn dev` in `/docs`. - -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/tannerlinsley/react-query) - -## Commit message conventions - -`react-query` is using [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines). - -We have very precise rules over how our git commit messages can be formatted. This leads to **more readable messages** that are easy to follow when looking through the **project history**. - -### Commit Message Format - -Each commit message consists of a **header**, a **body** and a **footer**. The header has a special -format that includes a **type**, a **scope** and a **subject**: - -``` -(): - - - -