With live subscriptions, has anyone centred on a g...
# prisma-whats-new
p
With live subscriptions, has anyone centred on a good approach for handling multi-user edits of text that is stored on graph.cool? (collaborative editing)
a
@phil I tried something. Created a Type to receive deltas. Used event hooks to merge changes into the source document (in another Type), client has subscription on the source document Type, so receives update after every persisted change. Client also needs the same logic to merge the received updated document with the local changes.
p
Super interesting. Thanks @agartha
How complex would you say that was to implement? And are you finding this a stable approach?
a
Not actively using it, did it as a PoC, actually before Graphcool, to prove the pattern worked.
It's easy to implement if you already have the business logic for the merge, because that's the hardest part
I extended it to do locking as well, I have the pattern ready, but I never got around to implement it. On the client, when the user sets focus on a field, I would add a lock record to a child Type, with information about the user, the record, and the active field, subscribe all clients to receive lock updates, update the UI accordingly (by making fields read-only). That prevented most of the merge conflicts.
p
Thanks @agartha