leather-io / mono

Leather monorepo
https://leather.io
MIT License
12 stars 5 forks source link

fix(query): fetch on mounts #650

Closed kyranjamie closed 3 days ago

kyranjamie commented 3 days ago

We've had a handful of caching-related sounding issues raised lately. Looking into this because of @camerow's comment here.

Because of the default very-aggressive React Query settings, we've gotten into the habit of setting the queries not to update with code like:

  refetchOnMount: false,
  refetchOnReconnect: false,
  refetchOnWindowFocus: false,

Unless we have a refetchInterval set—which in many cases we don't—this means that we never refetch the data, even if it is stale.

Typically, I'd say that we should we refetching on mount, at the very least. If the stale values are set correctly, it should also be fine to refetch on the others too. I think we should just go and change the default settings to be less aggressive in the QueryClient object, such that when we define query-level settings, we're describing when it should be fetching more often, not forcing them to refetch less frequently.