Say I define a useQuery that has a fetch-policy of ‘cache-only’ and also expose refetch for that query. Later on, I call refetch. Does that refetch call use the fetch policy of cache only (i.e., does it just check the cache?) or does it always make a request to the server?
Hey @Devin_C! That refetch
call would use a network-only
policy to ensure a request is sent to the server. The only time refetch
does not alter the fetch-policy is when the fetch-policy would already guarantee a network request (cache-and-network
, no-cache
, and network-only
).
Thanks! Appreciate the help here @jerelmiller
@jerelmiller do you happen to know if that same logic applies for fetchMore as well?
@Devin_C its similar in that it will guarantee a request to your server, but slightly different in how it achieves this. Because you can provide an updateQuery
function to fetchMore
, it sets the fetch-policy to no-cache
instead of network-only
so that the cache is only updated through the provided updateQuery
function.
Great – @jerelmiller thank you for the explanation