after adding the TError generic throughout the codebase, there are now several places where typescript gets cross. QueryOptions<string> for example used to work fine, but now demands that you provide an error type. In other places it's defaulted to Error.
It seems like a logical solution to just add this default everywhere. This means we're being consistent as well as not causing a breaking change.
Co-authored-by: Jack Ellis <jack.ellis@godaddy.com>
since the updater receives `T | undefined`, it is difficult to construct a `T` from that. oldData can legitimately be `undefined`, but since `getQueryData` can also return `undefined` at any point, it makes more sense to have the updater be able to return `undefined` as well, which also means that `data` itself can be `undefined`
* restore default config on cleanup
* Add test for nested configs
* Revert "restore default config on cleanup"
This reverts commit c7647a47a6.
* restore settings
* At least one failing test will pass
* Fix act warning
* Fix other test, copy suspense logic
* fix: clear cache timeouts
calling queryCache.clear() was empting the queries object but not tearing any of them down
this commit adds a clear method to the individual queries, which cancels timeouts and promises
queryCache.clear now loops through the queries and clears each one
I've also update the return type of queryCache.clear as it doesn't actually return anything
* fixup! fix: clear cache timeouts
Co-authored-by: Jack Ellis <jack.ellis@godaddy.com>
* feat: query cache provider
the query cache now comes from a context, meaning users can easily override and control the cache being used inside their application
* fix: track multiple query caches
this commit does the follwing:
track all active query caches added via the provider, handles mounting/unmounting
if creating a cache, ensure we only do it once
when unmounting an internally-created cache, make sure to clear it first
setFocusHandler now loops through all of the currently-active caches
* test: add in-depth tests around query cache providers
* style: format touched files
* fixup! style: format touched files
* docs: correct readme description
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
Co-authored-by: Jack Ellis <jack.ellis@godaddy.com>
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
* feat types: pass a paramter to `setQueryData` to infer the type
without this, one would have to cast the type returned.
* implement the same for `setQueryData`
* remove unnecessary import