Company
Date Published
Author
Khalil Stemmler
Word count
1069
Language
English
Hacker News points
None

Summary

The use of refetchQueries in Apollo Client is a common approach to re-render the UI after executing a mutation and changing something in the backend. However, it has its drawbacks, such as making multiple network round-trips and introducing complexity when dealing with multiple queries relying on the same data. In contrast, relying on Apollo Client's automatic cache normalization algorithm or update functions can be more efficient and reduce round-trips after mutations. The use of refetchQueries is generally recommended when you don't yet know how caching normalization works or if you're unable to return the changed data in a mutation response. Ultimately, the choice between refetchQueries and relying on caching normalization and update functions depends on your specific use case and performance requirements.