Prisma1: Relation onDelete : "violate the required relation"

Created on 13 Aug 2018  路  4Comments  路  Source: prisma/prisma1

Hi, when I try to delete anode A or B, it returns me an error. I saw that the onDelete: SET_NULL is not required, but I think this is an issue. Have you an idea about this ?

MODEL :

type Article {
    user: User! @relation(name: "MyArticles", onDelete: SET_NULL)
}

type User {
    article: [Article !]! @relation(name: "MyArticles", onDelete: SET_NULL)
}

MUTATION :

deleteArticle(id: ID!): Article!

return ctx.db.mutation.deleteArticle({ where: { id } });

The change you are trying to make would violate the required relation 'MyArticles' between Article and User

bu0-needs-info

All 4 comments

Have you tried to do onDelete: CASCADE instead?
Here is more information about the behaviour of cascading deletes: https://www.prisma.io/forum/t/help-with-cascading-deletes/3878/2?u=nilan.

Nop, the thing is that I don't want to delete anything.

Can you share a reproduction according to the bug report template? This looks like unexpected behaviour.

Well, my bad, I had a "not null" condition on my relationnal node. See #1795

Was this page helpful?
0 / 5 - 0 ratings

Related issues

notrab picture notrab  路  3Comments

AlessandroAnnini picture AlessandroAnnini  路  3Comments

Fi1osof picture Fi1osof  路  3Comments

sorenbs picture sorenbs  路  3Comments

dohomi picture dohomi  路  3Comments