Conditions for Cascading Deletes


#1

I refer to https://github.com/prisma/prisma/issues/2743 and understand perhaps there are some potentially undocumented features for cascading deletes.

Is the following possible using Prisma’s schema / cascading deletes:

Consider the following schema:

type User {
  id: ID! @unique
  email: String @unique
  password: String!
  isActive: Boolean @default(value:"true")
  roles: [Role!]!
  profile: UserProfile @relation(name:"UserProfile", onDelete: CASCADE)
}

type Role {
  id: ID! @unique
  name: String!
  system: Boolean
  type: String!
  users: [User!]!
}

type UserProfile {
  id: ID! @unique
  user: User! @relation(name:"UserProfile", onDelete: SET_NULL)
  firstname: String
  lastname: String
}

Note:
A User can have a number of roles (many to many), including one specific for them.
A User can have a UserProfile (one to one)

For deleting an existing user:

Using Prisma’s awesomeness I can use @relation to forge a cascading delete on the profile. Great!

Is it possible to also create a deletion on their specific user role (ie delete roles that are connected/related to the subject user and have attributes {type:“user”, system:true}) whilst disconnecting from all other roles? ie. have conditions for delete and disconnect?