如何在一个事务中进行关联插入和更新?

How make related insert and update in one transaction?

假设两个 tables:

People {
 id: uuid
 home_id: uuid
}

Homes {
 id: uuid
}

Table People 已填充。我想做的是插入一个新的 Home 并更新 home_id 字段 People table 同时。这可能吗?

我最终通过创建 HomeOwnership table { person_id: uuid, home_id: uuid } 并从 People[ 中删除 home_id 解决了这个问题=17=] table。然后我在 table 之间建立了外键关系。然后突变将如下所示:

mutation MyMutation($person_id: uuid = "some_id") {
  insert_home_one(object: {home_membership: {data: {person_id: $person_id}}}) {
    id
    home_membership{
      person{
        name
      }
    }
  }
}