Change all prefetchQuery
calls to ensureQueryData
or fetchQuery
#2616
Labels
prefetchQuery
calls to ensureQueryData
or fetchQuery
#2616
prefetchQuery
eats errors, which has the very annoying consequence that any error we run into in a loader manifests as theensurePrefetched
invariant failure in the component. We never see the real error, only the invariant failure. This means opening the browser console tells you nothing about what went wrong. See #2614 for an example of something made much harder to debug by this. It might also help a little with #2573.Options
fetchQuery
(docs, source) fetches data unless it's cached and non-stale.prefetchQuery
(docs, source is the same asfetchQuery
except it eats errors and returns nothing. 😶ensureQueryData
(docs, source) only callsfetchQuery
if there is no data in the cache, regardless of staleness. IfrevalidateIfStale
istrue
(defaultfalse
), it will callprefetchQuery
to revalidate if there is data in the cache but it's stale. By default, it will not do this, meaning it will simply return cached data if it's present, regardless of staleness.I'm a little torn between
fetchQuery
andensureQueryData
. I'm not sure we need the extra logic inensureQueryData
— I think when we run a loader, we do want to make sure the data is fresh because it's a page navigation. I think we want the app to behave as much like a traditional web app as possible. I also don't want to have to pass inrevalidateIfStale: true
everywhere, so I'd probably add aloaderPrefetch
function to theQueryClient
object if I wanted to useensureQueryData
.The text was updated successfully, but these errors were encountered: