-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
I'm shopping around a bit to find an alternative React data fetching library, and found swr and this library quite nice and to-the-point. What I'm missing though, in both libraries, is the ability to update multiple query results at the same time, possibly depending on their variables. In the case of react-query, that would be an alternative signature to setQueryData. So instead of this:
function setQueryData(
queryKey: string | [string, any],
data: any | ((data: any) => any),
options?: {
shouldRefetch?: boolean
}
)...rather something like this:
function setQueryData(
queryKey: QueryKey,
data: (data: any, variables: any) => any | void,
options?: {
shouldRefetch?: boolean
}
)This would be similar to the signature of the refetchQuery function, which also takes an "extended" query key (thereby allowing to refetch an entire group at once).
I aim to use a library like this one to replace the data fetching and cached data management in a mid-sized project of mine, currently done in Redux. I've already written a few little helper hooks with a similar API, and have found it way more ergonomic and easy to use. However, I do need to be able to update the cached results of various other calls, just like I would do with Redux-cached data. (Of course simply refetching is often the best option, but for smaller updates that are not business-critical just updating the cache is faster and good enough.)
Is this something you would be willing to add/support? Or does this maybe not fit with the library's philosophy, or maybe there are performance concerns for not having added it initially?
For completeness' sake, here's the same feature as I requested @ swr: