paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers

Home Page:https://paljs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PrismaDelete doesn't remove same model relations

whekin opened this issue · comments

commented

Let's say I want to have specialPosts along with posts in the User model (from the pal js example schema), like this:
image
image

I set /// @onDelete(CASCADE) on both posts and specialPosts. But apparently only posts get removed. After analysing prisma queries, it turns out the onDelete executes the same delete query twice (removing posts with author, not specialAuthor & author).

I checked out the original onDelete source code, and it seems that it finds the first field that references the parent model. Thus, it won't ever reach other relations on the same parent model.

Maybe it's possible to get relation name (if exists) and find the field taking it into account? In case if that's not possible I think the docs should say about it

Thanks

commented

@AhmedElywa Thank you for reply! It makes sense. I think paljs.com docs should mention it though

This issue request is in #284