8000 Add a `GraphQL.reload()` API · Issue #26 · jaydenseric/graphql-react · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add a GraphQL.reload() API #26
Closed
Closed
@jaydenseric

Description

@jaydenseric

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.
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0