# The latest on deep (cascading?) mutations/deletions via GraphQL

**URL:** <https://discuss.dgraph.io/t/the-latest-on-deep-cascading-mutations-deletions-via-graphql/15660>\
**Category:** GraphQL\
**Tags:** dgraph\
**Created:** [September 25, 2021, 2:17pm UTC](https://discuss.dgraph.io/t/the-latest-on-deep-cascading-mutations-deletions-via-graphql/15660 "2021-09-25T14:17:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellohello](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/hellohello/32/6323_2.png) [@hellohello](https://discuss.dgraph.io/u/hellohello)\
**Post date:** [September 25, 2021, 2:17pm UTC](https://discuss.dgraph.io/t/the-latest-on-deep-cascading-mutations-deletions-via-graphql/15660/1 "2021-09-25T14:17:53Z")

</div>

Looking for efficient GraphQL mutation format to delete something along the lines of: Author (id 123) and all of that author’s Posts (and potentially other nested item types within Posts, such as Media…).

I see year old posts on here which seem to come to the conclusion that it’s not possible via a single, cascading GraphQL mutation. So questions:

1. Has this changed since a year ago?

2. What is the best non-DQL, GraphQL-only way to go about this on Dgraph Cloud?

A) Is it to delete each type separately and specify each and every node id? Author {id: 123} and Posts [{id: 234}, {id: 567}…] and Media[{id:789},{id:0123]…?

~~B) Is it to delete each type separately: Delete Media filtered where associated Posts = [{id: 234}, {id: 567}…] and Delete Posts filtered where associated Author = {id: 123} and Delete Author {id: 123}…?~~

Ah yes, looks like Dgraph still does not allow deep filtering so it seems B is not possible.

C) Or is there now a deep/cascading method for mutations?

Thanks.

---

<div class="post-metadata">

**Author:** ![jdgamble555](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jdgamble555/32/7503_2.png) [@jdgamble555](https://discuss.dgraph.io/u/jdgamble555)\
**Post date:** [September 25, 2021, 7:40pm UTC](https://discuss.dgraph.io/t/the-latest-on-deep-cascading-mutations-deletions-via-graphql/15660/2 "2021-09-25T19:40:09Z")

</div>

Currently there is no way to do this in Dgraph except manually. This includes **dql** and **graphql**.

I have proposed a [Reference Directive](http://discuss.hypermode.com/t/feature-request-cascade-delete-deep-mutations-by-reference-directive/14658) which mimics **SQL** ’s

- `ON DELETE CASCADE`
- `ON UPDATE CASCADE`

However, Dgraph has not shown any interest in adding this _basic foreign key feature_ in the future.

For the moment, you can only emulate this with a `delete` and `update` [Lambda Webhook](https://dgraph.io/docs/graphql/lambda/webhook/). This is basically an After (add/delete/update) Trigger Function.

J

---

<div class="post-metadata">

**Author:** ![hellohello](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/hellohello/32/6323_2.png) [@hellohello](https://discuss.dgraph.io/u/hellohello)\
**Post date:** [September 26, 2021, 3:59pm UTC](https://discuss.dgraph.io/t/the-latest-on-deep-cascading-mutations-deletions-via-graphql/15660/3 "2021-09-26T15:59:21Z")

</div>

OK, thank you Jonathan.
