变异操作的 GraphQL 顺序

GraphQL order of mutation operations

我正在创建一个有效的突变,但我不确定它是否按照我认为的方式工作。但是,我想知道执行顺序是什么?

我想确保在执行 insert/upsert 之前从 table 中删除某些项目。使用以下突变查询字符串,这是否总是会做我想做的事情,还是会时不时地工作,因为我假设它是同步的,但实际上它是异步的?

mutation MyMutation(...) {
  update_my_table_1(...) { }

  delete_my_table_2(...) { }

  insert_my_table_2(...) { }
}

来自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.

根突变类型的字段始终按顺序解析。任何 other 类型(如查询根类型或任何“嵌套”类型)的订单字段是 left up to the implementation,尽管在大多数(如果不是全部)实现中它意味着字段是并行解决。

所以在上面的例子中,insert_my_table_2直到delete_my_table_2才执行,delete_my_table_2直到update_my_table_1才执行。