It seems cache exchange caches errors as well #3489
-
I'm using urql client for the static website where graphql queries are executed mostly on the backend. I'm using urql with following exchanges configuration: exchanges: [
requestPolicyExchange({
ttl: 3 * 60 * 1000, // 3 minute.
}),
cacheExchange,
fetchExchange,
], The idea is to cache response from CMS between different user request (all responses are public). The problem is that urql cache exchange also caches error responses, and even network errors. This causes that site might be down for 3 minutes if some network glitch between client and cms api occured. I understand why this default exchange might want to cache errors as well, since graphql could send partial data alongside with errors, however I noticed that this happened for network errors as well, which is weird. What I want to know, is that a way to skip caching result if there is at least one error (event if some partial data returned) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You might want to try the |
Beta Was this translation helpful? Give feedback.
You might want to try the
retryExchange
here to ensure you aren't delivering errors. The defaultcacheExchange
is very much focussed on a single user client side way of working, you could however change this yourself by forking the exchange and changing this line to opt out of caching errors, the document cache will cache as long as there is data present.