paljs / prisma-tools

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

onDelete.deleteParent == true does not return the parent object #152

Closed ObserverMoment closed 3 years ago

ObserverMoment commented 3 years ago

Hi Ahmed,

I've just discovered your select and delete packages - they are really great and making my code so much more straightforward!! Thank you for your work in making these!

I am using the delete package to remove an object and its descendants. I want the parent object to return once this is completed, so that I can check that the operation was successful and then do some further processing on related objects. I am currently just getting back null.

From your paljs docs:

deleteParent A flag to determine whether the model should be deleted and returned when its defined as true

I may be missing something but the source code for PrismaDelete.onDelete doesn't appear to be returning a value? Am I doing something wrong?

https://github.com/paljs/prisma-tools/blob/1ce502618d3f0c9809d8e26083950da8fbcaef3d/packages/plugins/src/delete.ts#L150

  // Cascade delete reliant descendants with https://paljs.com/plugins/delete/
  const deleted = await prisma.onDelete({
    model: 'User',
    where: { id: id },
    deleteParent: true,
  })
AhmedElywa commented 3 years ago

Thanks for reporting

ObserverMoment commented 3 years ago

Nice!