I have a Relay app and I want to clear cache for a component that displays after logging in. I tried passing a currentRelay.store into my Relay.Router and implementing a currentRelay.reset() which sets that store to a new Relay.Environment, then calling that after logout. The cache is still stored for some reason. I also tried calling this.props.relay.forceFetch({}) and this.forceUpdate() in componentDidMount(). The only way I can get the cache to clear is by manually refreshing the page. I wonder if there's a bug in Relay.Environment or I'm doing it wrong.
Asked
Active
Viewed 1,337 times
0
-
Did you try out this https://github.com/facebook/relay/issues/1025#issuecomment-207162568? – Ahmad Ferdous Aug 16 '16 at 22:38
-
That's more or less what I'm doing. Did that work for you? – Andrew Fader Aug 17 '16 at 02:25
1 Answers
0
in a environment file just get response cache from QueryResponseCache which you can get from relay-runtime im using 8.0.0 so you can check your verison of relay runtime and get queryresponsecache from relay-runtime
const cache = new QueryResponseCache({ size: 250, ttl: oneMinute });
after jutst get token from localstorage if token is null then do cache.clear() e.g,
if (!token) {
cache.clear();
}

Mayank Pandav
- 425
- 5
- 20