Say I have this schema:
Client {
services: [Service] @relation(name: "ClientServices")
}
Service {
clients: [Client] @relation(name: "ClientServices")
}
And I want to connect some services to a client, like this:
mutation {
updateClient(id: ..., data : {
services: {
connect: ["123", "456"] ## where there are valid service _id's
}
}) { ... }
}
Fantastic. Works great. But now I want to replace all the connections (services) with other ones, but still keep the 123 service.
mutation {
updateClient(id: ..., data : {
services: {
connect: ["123", "789"] ## notice kept 123, and now want 789
}
}) { ... }
}
This will result in a instance not unique
error from Fauna. Because its trying to connect 123 but its already in the ClientServices collection (the auto-generated collection that manages m-m relationships.)
Is there an easy way to disconnect all and reconnect the ones I want in one call without a UDF?