Some scenarios required multiple mutations to be executed atomically. This should be implemented using GraphQL directives.
:1st_place_medal: Would be a wonderful addition! Would clean up some controllers in my app for sure :D
Thanks for the feedback @emolr! What is your current approach to handle this?
Hey! Sorry for the late response didn't see your question @marktani.
If i understand it correctly, It could help me when i'm creating an account, adding the logged in user to the account and creating a campaign and creating the relation to the newly created account at the same time.
So it could be something like a createAndAddUserToAccount directive where mutation 1 is: createAccount, and mutation 2: addUserToAccountUsers inheriting the created Account.id.
Is it something like this Atomic GraphQL mutations means?
Because now i create Account, wait for success then receive the id of the Account, then add the User to the Account, but "manually" from my client
You can "fake" this (in a very hacky way) but introducing a mutation that wraps a set of actions as its input argument, along with the remaining data. We are using that approach while we look into making mutations directly atomic.
If there is a mutex function in the graph cool library , we can make our own atomic functions in the request pipeline.
As an example
mutex.lock("some_atomic_mutation");
... run queries and atomic updates ...
mutex.unlock("some_atomic_mutation");
I built a simple library, that adds those mutex functions to the graphcool-lib library:
https://github.com/AgarthaSolutions/graphcool-mutex
closing in favor of https://github.com/graphcool/framework/issues/1349
Most helpful comment
I built a simple library, that adds those mutex functions to the
graphcool-liblibrary:https://github.com/AgarthaSolutions/graphcool-mutex