Reputation: 2767
There is a detailed explanation in https://facebook.github.io/relay/docs/thinking-in-graphql.html article how Relays caching works.
But it doesn't described what to do if I'd like to refresh my local storage from server data with the same query. According to Relay logic it will look at the query, find it fullfilled locally and returns data from local storage.
But how to avoid caching and force Relay to send a new request to server?
Upvotes: 1
Views: 1579
Reputation: 3399
You can have Relay send a request to refetch all data by using forceFetch
API.
For example, if you have a button in your React component to refresh data and if the handler function is refreshData
, call forceFetch
in that function:
refreshData() {
this.props.relay.forceFetch();
}
Upvotes: 5