paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
687 stars 55 forks source link

PrismaDelete doesn't remove same model relations #279

Closed whekin closed 1 year ago

whekin commented 2 years ago

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

AhmedElywa commented 2 years ago

Hi @whekin, We dropped this class a long time ago because Prisma support this now https://www.prisma.io/docs/concepts/components/prisma-schema/relations/referential-actions#types-of-referential-actions

whekin commented 2 years ago

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

AhmedElywa commented 1 year ago

This issue request is in #284