Hi. Does GraphQL kotlin preserve order of certain ...
# graphql-kotlin
d
Hi. Does GraphQL kotlin preserve order of certain functions send in one graphql request? I have something like this:
Copy code
mutation {
  deleteObj1(where){
    affectedRows
  }

  deleteObj2(where){
    affectedRows
  }

  deleteObj3(where){
    affectedRows
  }

  deleteObj4(where){
    affectedRows
  }
}
If order of executed functions will change, there can be thrown foreign key constraint condition -> I need to execute mutations like DELETE CASCADE...
l
The actual graphql executor comes from graphql-Java, and I’m sure it’s spec-compliant and runs mutations in sequence, top to bottom. But if you need transactionality, you should really wrap these up in a single mutation
d
if you use
graphql-kotlin-spring-server
then by default yes they will execute sequentially, that being said - as was pointed above I’d highly recommend to refactor your schema to expose single mutation that handles all of that
*you could manually manage transaction around the whole request but I think it would be much simpler in single mutation
see: https://graphqlme.com/2018/05/13/transactions-mutations-and-graphql/ for a pretty good write up on this topic
c
Treat each mutation independently. Just like with resolvers, how you execute (serially, sequentially) is implementation detail.