Re:GraphQL and Caching
by latchkey on Friday September 27, 2019 @03:29AM
(#21089369)
I'm certainly no expert in this, but I have been working with it a lot recently while developing an app using graphql.
The solution in Apollo is to do caching in the client (and the server). This means that if you add something to a list of items on the client side, you're going to have to manually update the client cache or fetch it all fresh again. It is a pain to get used to this at first, but it turns out to not be that bad and I can see how it gives a lot of flexibility. As far as I can tell, there is no good 'built in' caching like this for rest based apps (ie: using localStorage), you're always re-inventing it.
The UX changes a bit in SPA's. User clicks on a tab and sees a loading section. When the user clicks away from the tab and then back, it is right there without having to reload. The data is pulled out of localStorage automatically by Apollo client. Makes things feel really snappy. If the user wants to see a new version of the data, they click the refresh button.
The solution in Apollo is to do caching in the client (and the server). This means that if you add something to a list of items on the client side, you're going to have to manually update the client cache or fetch it all fresh again. It is a pain to get used to this at first, but it turns out to not be that bad and I can see how it gives a lot of flexibility. As far as I can tell, there is no good 'built in' caching like this for rest based apps (ie: using localStorage), you're always re-inventing it.
The UX changes a bit in SPA's. User clicks on a tab and sees a loading section. When the user clicks away from the tab and then back, it is right there without having to reload. The data is pulled out of localStorage automatically by Apollo client. Makes things feel really snappy. If the user wants to see a new version of the data, they click the refresh button.
https://www.apollographql.com/docs/react/caching/cache-inter...
https://www.apollographql.com/docs/apollo-server/performance...