Graphql-ruby: Batch Mutations?

Created on 13 Jul 2018  路  1Comment  路  Source: rmosolgo/graphql-ruby

I was wondering if there was support to send multiple mutation requests at the same time? It doesn't seem to be listed on the docs from what I can tell, all I could see support for was batching queries.

Something like:

mutation {
  saveResource1 {
    result
  }
  saveResource2 {
    anotherResult
  }
  ...
}

Is there any support through this gem for this functionality?

Most helpful comment

I expect the example that you posted would work fine out of the box! Did you get an error, or some misbehavior, when you tried it?

You don't see a lot of examples with multiple mutations because of the problem of _transactions_. Each mutation is run as its own unit, so what happens if saveResource1 succeeds, but saveResource2 fails? The client (and perhaps even the backend) could be in a very odd state, halfway though some important process.

When there's only one mutation in an operation, it's easier to be sure that the operation will be _transactional_: either the whole thing will succeed, or the whole thing will fail. But with multiple mutations, it's a bit trickier!

Anyway, I _expect_ that example to work fine, but if you give it a try and something goes wrong, feel free to reopen this issue! Happy to continue discussion too, but I'll close this since I don't think it requires any changes to the library yet.

>All comments

I expect the example that you posted would work fine out of the box! Did you get an error, or some misbehavior, when you tried it?

You don't see a lot of examples with multiple mutations because of the problem of _transactions_. Each mutation is run as its own unit, so what happens if saveResource1 succeeds, but saveResource2 fails? The client (and perhaps even the backend) could be in a very odd state, halfway though some important process.

When there's only one mutation in an operation, it's easier to be sure that the operation will be _transactional_: either the whole thing will succeed, or the whole thing will fail. But with multiple mutations, it's a bit trickier!

Anyway, I _expect_ that example to work fine, but if you give it a try and something goes wrong, feel free to reopen this issue! Happy to continue discussion too, but I'll close this since I don't think it requires any changes to the library yet.

Was this page helpful?
0 / 5 - 0 ratings