OlegTheCat
OlegTheCat

Reputation: 4513

What's the correct GraphQL behaviour when error occured in the middle of execution of multiple mutations?

Let's say we have the following query (taken from the spec):

mutation Root {
  first: changeTheNumber(newNumber: 1) {
    theNumber
  }
  second: changeTheNumber(newNumber: 3) {
    theNumber
  }
  third: changeTheNumber(newNumber: 2) {
    theNumber
  }
}

Assuming the error occured during execution of second mutation, how GraphQL server implementation should act in such case: should the third mutation be evaluated or something else?

Upvotes: 0

Views: 84

Answers (1)

Ahmad Ferdous
Ahmad Ferdous

Reputation: 3399

According to the JavaScript reference implementation for GraphQL, the same mutation changeTheNumber of the selection set will be executed in the given order. If error occurs in the second mutation, its result will be an Error object. The following mutations in that selection set will not be aborted.

Upvotes: 1

Related Questions