TallerWebSolutions / apollo-cache-instorage

Apollo Cache implementation that facilitates locally storing resources
MIT License
96 stars 11 forks source link

apollo-cache-hermes support #1

Closed Enalmada closed 4 years ago

Enalmada commented 5 years ago

What do you think about supporting hermes cache? https://github.com/convoyinc/apollo-cache-hermes I am using InMemoryCache right now but curious if hermes might offer better performance for the average user. It seems to handle cache by id better out of the box.

I am also using next.js and got curious about apollo-cache-persist but sadly it seems they don't support merging of cache, which is the issue where I saw a post about this solution. The fact that this solution seems to merge persisted and hydrated cache is interesting. Would you recommend that apollo-cache-persist merge cache in the same way you do?

I also assume that storage could take in https://github.com/localForage/localForage rather than "window.localStorage"? It might be nice to have that in the documentation as an option if it is a drop in replacement. I am under the impression that localForage might better support a wider range of browsers.

lucasconstantino commented 5 years ago

First, I'm not really familiar with apollo-cache-hemers. I've read the library, but I'm not sure how much of a benefit it would be in contrast with my current solution - nor what should do to make it integrate with Hermes cache. I guess I would have to extend from that type, but I wonder if that wouldn't limit use cases, as Hermes is not a drop-in replacement, really.

Second, I totally think that apollo-cache-persist should better handle the hydration vs persistence problem, and yes, I think my solution is an option. But honestly, there are still some buggy behaviors I'm experiencing with this merge that perhaps is due to my limited knowledge on the caching format. By the way: Hermes cache would change that considerably, so perhaps I wouldn't dive into as many bugs using that Cache as the base for mine. Not sure.

Third, in the README I state that the storage must be complient to the Web Storage spec. If localForage is complient as it seems, you should have no problem using it as a drop-in. If that's not the case - and this is not yet properly documented - you can still implement an interface to adapt it.

Ps.: thanks for trying out this project. I think it addresses a huge current pitfall of the Apollo client stack, yet I don't see many people complaining so far.