apollographql / apollo-cache-persist

🎏 Simple persistence for all Apollo Cache implementations
MIT License
1.39k stars 118 forks source link

[Question] Collaborative / multiplayer caching / syncing engine? #503

Closed WillTaylor22 closed 1 year ago

WillTaylor22 commented 1 year ago

Hi team, thanks for the great library.

Am I correct in understanding that neither this library nor any other part of the apollo ecosystem supports multiplayer caching, with a "catch up" function for users when they log back in? I.e. that when a user returns to a shared resource, changes to the resource can be requested, sent and updated in the local version, without invalidating the entire cache?

To give a basic example, suppose two users have a shared to-do list

wodCZ commented 1 year ago

Hi Will,

I'll slightly correct you. Apollo ecosystem (nor any other graphql ecosystem I know) doesn't provide a "catch up" mechanism out of the box, and leaves that up to you. You can create a query on your backend, receiving a changesSince: Date argument that would return any records modified since User 1's last update, and write a custom cache policy that would merge the results with existing records.

That of course doesn't by itself take care of deleted records, and it is not a generic plug'n'play solution.

So, apollo ecosystem supports such mechanisms, but doesn't provide any actual implementation of such, at least to my knowledge.

If that's a crucial requirement in your app, you might want to look in the directions of watermelon db or similar.

WillTaylor22 commented 1 year ago

Thanks wodCZ - super helpful. I'll check out watermelon db too.

For those interested in the same question, my research yesterday uncovered a couple of collaboration-focussed data management tools (which can sit alongside Apollo) to explore here https://npmtrends.com/@convergence/convergence-vs-automerge-vs-gun-vs-orbit-db-vs-racer-vs-sharedb-vs-yjs