#Best way to globally handle query keys?

2 messages · Page 1 of 1 (latest)

bright ice
#

I have a use case where the presence of certain query params in the current url need to be added to all outgoing requests. ex. current url = "www.foo.com?bar=1". "bar=1" would be added as query params to all outgoing requests. "bar" would of course need to be added to the queryKey when calling useQuery(). Does RQ provide a way to configure this globally? Another approach would be for all consumers of useQuery() to call a shared util like "addUrlQueryParams()" when forming the query key.

where addUrlQueryParams() is something like:

function addUrlQueryParams(queryKey = []) {
   return queryKey.concat( add current url query params here... );
}
neat ridge