My Home Page contains a cell. When I navigate back to the HomePage from a different page, the cell doesn’t seem to refresh. Is there a way do this ?
Not entirely sure, but my hunch is that Apollo is reading your query results from its cache.
You’ll want to change the fetchPolicy
for this query: https://www.apollographql.com/docs/react/api/react-apollo/#optionsfetchpolicy
You can export a beforeQuery
next to your QUERY
to enable this. This is also the default behaviour generated for scaffolds!
export const beforeQuery = (props) => {
return { variables: props, fetchPolicy: 'cache-and-network' }
}
5 Likes
As mentioned by @Robert it could probably be the cache. i.e the mutation isn’t updated in the local cache. If it is the cache, I would add the update
function in my mutation to update the cache, instead of fetching it from the db. There is a chrome extension to inspect the apollo cache.
2 Likes
Fetch policy fixed it. Thanks for your help!
3 Likes