ra-data-opencrud icon indicating copy to clipboard operation
ra-data-opencrud copied to clipboard

Allow soft-deletion ?

Open Weakky opened this issue 7 years ago • 1 comments
trafficstars

In prisma-ecommerce, I have several models that I need to be soft-deleted only, such as Products so that Orders remains intact.

I see two ways of achieving this:

  • Either we add another mutation type PRISMA_SOFT_DELETE (along with the present PRISMA_CONNECT, PRISMA_CREATE etc..), and behave accordingly

  • Or we look for a special field in models (eg: deletedAt), and always soft-delete those fields.

Note: we will have to filter all subsequent queries to remove soft-deleted nodes. (where: { deletedAt: null }

Any feedback would be much appreciated.

Weakky avatar Aug 27 '18 19:08 Weakky

I came across this issue while searching for soft-delete for ra-data-graphql. I don't want to hijack this issue, but think there might be some overlap here.

On the ra-data-graphql side of things causing the soft-delete to happen is easy since we are in control of the Mutation being called, but I suspect there may be a change needed in the core to support this.

Currently when I delete a single item from an Edit page, or bulk delete multiple items from the List page, those items are optimistically removed from the List page, and a new query is made to refresh the results.

In the normal case this would usually pull in X items from the next page, but in the soft-delete case the recently deleted items reappear.

Would it make sense to add a flag to the list view to not optimistically remove deleted items? I think this would be needed by any DataProvider wishing to support soft-delete.

m14t avatar Dec 19 '18 03:12 m14t