Imagine two tables:
People {
id: uuid
home_id: uuid
}
Homes {
id: uuid
}
Table People is already populated. What I would like to do, is to insert a new Home and update home_id field in the People table at the same time. Is this possible?
I ended up solving this by creating a HomeOwnership table { person_id: uuid, home_id: uuid }
and removing home_id
from the People table. Then I established foreign key relationships between the tables. Then the mutation would look like following:
mutation MyMutation($person_id: uuid = "some_id") {
insert_home_one(object: {home_membership: {data: {person_id: $person_id}}}) {
id
home_membership{
person{
name
}
}
}
}