morpheus-graphql
morpheus-graphql copied to clipboard
Concurrent Execution for Query and Subscription, but Serial for Mutation
Can you elaborate? Under the hood what are shared between executions (query/mutation/subscription)? Why can't we do mutations concurrently?
Why can't we do mutations concurrently?
it is GraphQL
specification:
Serial execution of the provided mutations ensures against race conditions during these side‐effects.
https://graphql.github.io/graphql-spec/June2018/#sec-Mutation
how we can implement it, is another question.
Ahh, it says that in each request, top-level selection set of mutation should be executed in sequence. This makes senses.
At first I thought all the mutation requests send to server should be processed serially (which is hindsight, morpheus has no control over that).
but i think we have control over Execution. ResultT m
transformer can decide how to execute monad m
for lists
and object fields
.
but i think we have control over Execution.
ResultT m
transformer can decide how to execute monadm
forlists
andobject fields
.
Yeah. But not over a scotty webserver where requests are processed concurrently, right?
@dandoh could you evaluate. how we could implement it?
i don't deep knowledge of it but may they do what we want.
- https://hackage.haskell.org/package/base-4.11.1.0/docs/Control-Concurrent.html
- https://hackage.haskell.org/package/parallel-3.2.2.0/docs/Control-Parallel-Strategies.html#history
the idea is that according to typeVariable (concurency :: Bool)
Result
and ResultT
https://github.com/morpheusgraphql/morpheus-graphql/blob/7c4bc7c968353f6bb1378350f6b2adf0fc145474/src/Data/Morpheus/Types/Internal/Resolving/Core.hs#L108-L110
and
https://github.com/morpheusgraphql/morpheus-graphql/blob/7c4bc7c968353f6bb1378350f6b2adf0fc145474/src/Data/Morpheus/Types/Internal/Resolving/Core.hs#L138-L140
change execution strategy (serial vs parallel).
or
https://github.com/morpheusgraphql/morpheus-graphql/blob/7c4bc7c968353f6bb1378350f6b2adf0fc145474/src/Data/Morpheus/Types/Internal/Resolving/Resolver.hs#L374-L379
just concentrate to serially execute fields on mutations
I might have some ideas, but let me do experiments first.
i think it works perfectly without. if someone will require this feature we can reopen it