Reputation: 36299
I am creating a mutation which works but I am not sure if it is working the way that I think it is. However, I would like to know what is the order of execution?
I want to make sure that certain items are deleted from a table before the insert/upsert is executed. Using the following mutation query string, will this always do what I want or will it not work from time-to-time because I assume it is Synchronous but in reality it is Asynchronous?
mutation MyMutation(...) {
update_my_table_1(...) { }
delete_my_table_2(...) { }
insert_my_table_2(...) { }
}
Upvotes: 6
Views: 2223
Reputation: 84667
From the spec:
If the operation is a mutation, the result of the operation is the result of executing the mutation’s top level selection set on the mutation root object type. This selection set should be executed serially.
It is expected that the top level fields in a mutation operation perform side‐effects on the underlying data system. Serial execution of the provided mutations ensures against race conditions during these side‐effects.
Fields on the root mutation type are always resolved sequentially. The order fields of any other type (like the query root type, or any "nested" types) is left up to the implementation, although in most if not all implementations it means the fields are resolved in parallel.
So in the above example, insert_my_table_2
won't executed until delete_my_table_2
is, and delete_my_table_2
won't be executed until update_my_table_1
is.
Upvotes: 7