You've now learned two methods for updating data after it's been changed:
- Refetch the related queries.
- Modify Apollo's cache.
Refetching can be a bit slower, but ensures that the data on the frontend remains in sync with the server. Modifying the cache can be faster, but risks the data getting out of sync if you're not careful.
Which one is right? The approach you take depends on three things:
- Who has access to this data?
- How frequently is it likely to change?
- How important is it for the frontend and server to stay in sync all the time?
Coming up next, we'll learn a strategy that can help mitigate the risk of updating the cache instead of refetching.