Closed
Description
A GraphQL.reload()
API would trigger a GraphQL
reload
event, but not actually delete any cache like GraphQL.reset()
does. It would have the same ability to preserve the cache for a particular operation via an exceptCacheKey
option.
The useGraphQL()
React hook option resetOnLoad
will need rethinking. Although we could just add another reloadOnLoad
option, it doesn't make sense that a user could set both options to true
at once.
Use cases:
GraphQL.reset()
:- The user logs out, so immediately scrub all their data from the cache. Parts of the page with queries that load on mount, such as the header, will revert to a blank loading status while fresh data is loaded. The
exceptCacheKey
option is used to ensure that the mutation payload is preserved so that the logout success status and message stays visible to the user.
- The user logs out, so immediately scrub all their data from the cache. Parts of the page with queries that load on mount, such as the header, will revert to a blank loading status while fresh data is loaded. The
GraphQL.reload()
:- A mutation has happened where parts of the cache could be stale (e.g. the user changed their name), so you want all queries to reload optimistically. They render with their old cache while loading fresh cache in the background, instead of reverting to a blank loading state.