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' }
}
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.
Fetch policy fixed it. Thanks for your help!
Hi
Could you please tell me in detail how you solved this problem?
Do this in the cell you don’t want to use cache
export const beforeQuery = (props: unknown) => {
return {
variables: props,
fetchPolicy: 'no-cache',
}
}
I was encountering caching issues in an edit cell when I added some additional data/fields to the form. The issue was resolved by editing the data returned by the update mutation to include the newly added fields.