-
Hi all. I'm using pathom3 to abstract across lots of different sources of data. It has been straightforward blending read-only views, but I'm now attacking the mutation side of things. One data source is PostgreSQL. One option is for me to define the mutation in terms of new values and old values, and use optimistic locking to do the UPDATE ensuring the data is as was before. That does feel as if I'm leaking an abstraction however to the client application. How have others handled optimistic locking, or any other form of locking, in mutations? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello Mark. Pathom by itself doesn't have any locking mechanisms. One thing it does about mutations is that it runs them before running the read parts (although a mutation subquery will run before other mutations). What kind of locking do you have in mind? Can you make an example situation to demonstrate what is lacking to achieve what you need? |
Beta Was this translation helpful? Give feedback.
-
Thanks Wilker. You are right it is not an issue for pathom directly. I am half-way between an old world of change-in-place semantics and traditional relational databases with tables that I update and the new world of immutable data accumulating with read-only properties/graphs and operations/actions/mutations as first-class. So anything new I'm building properly, but I have to deal with legacy. But that is fine. I can make optimistic locking a way to make it safe, and it is dependent on the context and the domain how important it is for users to not clash in writing to the same record. Indeed, thinking about more, I realised it isn't something to be left as a default, but an important first-class 'thing' and if a user saves a change and someone else has edited, I can model that and feedback. So all fine and solved - I simply send along the old with the new and do an update in which the row is updated only if the old values are still current, and send back a status. Thank you. Mark |
Beta Was this translation helpful? Give feedback.
Thanks Wilker. You are right it is not an issue for pathom directly.
I am half-way between an old world of change-in-place semantics and traditional relational databases with tables that I update and the new world of immutable data accumulating with read-only properties/graphs and operations/actions/mutations as first-class. So anything new I'm building properly, but I have to deal with legacy. But that is fine. I can make optimistic locking a way to make it safe, and it is dependent on the context and the domain how important it is for users to not clash in writing to the same record. Indeed, thinking about more, I realised it isn't something to be left as a default, but an important fir…