Cache update does not rerender
john-dominguez opened this issue · comments
Issue:
When adding a new Employee, ApolloCacheUpdater successfully updates the cache but does not trigger a re-render ( shown once the page is refreshed).
Info:
REMOVE is working as intended and triggers a re-render upon completion.
Client Options:
fetchPolicy: 'cache-and-network',
errorPolicy: 'all',
notifyOnNetworkStatusChange: true,
returnPartialData: true
Image
The following image shows:
- Console log: Created Employee & ApolloCacheUpdater ran successfully
- Apollo Extension: Shows the Employee in cache
- Table: Empty table
- employees object: data object from
const { loading, data, refetch } = useQuery(GET_EMPLOYEES)
Solved:
Setting the fetchPolicy to 'cache-first' fixed the issue.
There's an edge case of when the table is empty and you create a new item it does not force a UI Update.
@john-dominguez if you create a small repo reproducing the issue I'll be happy to have a look 👍
@john-dominguez if you create a small repo reproducing the issue I'll be happy to have a look 👍
Apologies, i couldn't figure out why it wasn't initially working. It is fixed now that i changed my rendering.