Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Reset cache by especific query or mutation #2206

Closed
bdouram opened this issue Jul 23, 2018 · 3 comments
Closed

Reset cache by especific query or mutation #2206

bdouram opened this issue Jul 23, 2018 · 3 comments

Comments

@bdouram
Copy link

bdouram commented Jul 23, 2018

Hi!
I want to use the client of react-apollo to reset part of the cache from a key or query, not clean the entirely cache using the client.resetStore().

Example:

import { withApollo } from "react-apollo";
import { compose } from "recompose";
import MyComponent from "./MyComponent";

const cleanEspecificCache = ({ client }) => () =>{
  // What i do here?
}

const enhance = compose(
 withApollo,
 withHandlers({cleanEspecificCache})
)

export default enhance(MyComponent);

What i do to make it works? Thanks!

@htulipe
Copy link

htulipe commented Aug 20, 2018

I filed a feature request for what looks like your need: apollographql/apollo-feature-requests#29 please upvote

@rosskevin
Copy link
Contributor

Use writeQuery or writeData depending on your needs.

@radireddy
Copy link

A simple way to reset the cache for a specific query is to call the query again with fetchPolicy: 'network-only'. GraphQL fetches data from API and updates the cache after results are received.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants