Describe the bug
I'm implementing a following feature using many-to-many self-relation,
let's say X is following Y and Z
when I disconnect X/Y, X/Z got disconnected to
To Reproduce
Steps to reproduce the behavior:
this is my schema
type User {
id: ID! @unique
follower: [User!]! @relation(name: "UserFollow")
following: [User!]! @relation(name: "UserFollow")
}
first connect X/Y and X/Z
mutation {
updateUser(data:{
following: {
connect: [{ id: "Y" }, { id: "Z"}]
}
},where:{
id:"X"
}) {
id
}
}
then disconnect X/Y
mutation {
updateUser(data:{
follower: {
disconnect: [{ id: "X" }]
}
},where:{
id:"Y"
}) {
id
}
}
this is what is got from MySQL log
delete from `test@dev`.`_UserFollow`
where `test@dev`.`_UserFollow`.`B` = 'X'
so it deletes all relations that X is following
Expected behavior
delete only the relation between X/Y
Versions (please complete the following information):
prisma CLI: prisma/1.12.0 (linux-x64) node-v9.11.1Post - Category many-to-many
Datamodel
`
type Post {
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
title: String!
content: String!
isPublished: Boolean @default(value: true)
categories: [Category!]!
}
type Category {
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
title: String!
parent: Category @relation(name: "CategoryParent")
children: [Category !]! @relation(name: "CategoryChildrens")
posts: [Post!]!
}
Mutation
mutation {
updatePost(data: { categories: { disconnect: [{ id: "CAT2"}, {id: "CAT5"}, {id: "CAT8"}] }, where {id: "POST1"} })
}
`
exemple
_PostToCategory
before update
| id | A | B
| .... | Post1 | CAT1
| .... | Post1 | CAT2
| .... | Post1 | CAT5
| .... | Post1 | CAT8
| .... | Post2 | CAT4
| .... | Post2 | CAT5
| .... | Post2 | CAT8
after update
| id | A | B
| .... | Post1 | CAT1
| .... | Post2 | CAT4
Versions :
OS: windows 10
prisma CLI: prisma/1.12.0, Mysq/5.7, node-v8.11.1
Prisma Server: 1.12.0
Docker Community Edition: 18.06.0-ce-win72 (19098)
Hey @geniusgordon and @salim-dev ,
thanks for reporting this and the detailed reproductions. I can reproduce it and will fix it right away.
Most helpful comment
Hey @geniusgordon and @salim-dev ,
thanks for reporting this and the detailed reproductions. I can reproduce it and will fix it right away.