# How to delete objects based on nested objects' fields

**URL:** <https://discuss.dgraph.io/t/how-to-delete-objects-based-on-nested-objects-fields/11275>\
**Category:** GraphQL\
**Tags:** kind:question\
**Created:** [November 3, 2020, 5:04pm UTC](https://discuss.dgraph.io/t/how-to-delete-objects-based-on-nested-objects-fields/11275 "2020-11-03T17:04:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![catherineluse](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/catherineluse/32/4329_2.png) [@catherineluse](https://discuss.dgraph.io/u/catherineluse)\
**Post date:** [November 3, 2020, 5:04pm UTC](https://discuss.dgraph.io/t/how-to-delete-objects-based-on-nested-objects-fields/11275/1 "2020-11-03T17:04:30Z")

</div>

Based on reading the docs, I don’t think something like [this](https://hasura.io/docs/1.0/graphql/core/mutations/delete.html#delete-objects-based-on-nested-objects-fields) is possible with Dgraph GraphQL, but I wanted to confirm.

I know you can delete objects based on primitive fields with the @search directive. But let’s say I have a comment type and a discussion type, and I want all the comments to be deleted when the discussion is deleted.

Right now in my project, I am first doing a query to get all the comments in the discussion that needs to be deleted. Then I delete all the comments. Then I delete the discussion. Is this a good practice or can some of those steps be combined?

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [November 3, 2020, 6:26pm UTC](https://discuss.dgraph.io/t/how-to-delete-objects-based-on-nested-objects-fields/11275/2 "2020-11-03T18:26:44Z")

</div>

Not available at this time. I have requested a similar feature and was informed that it is only possible right now either the way you are doing it, or with a DQL mutation. [How to delete with cascade? - #3 by pawan](http://discuss.hypermode.com/t/how-to-delete-with-cascade/10232/3)

---

<div class="post-metadata">

**Author:** ![catherineluse](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/catherineluse/32/4329_2.png) [@catherineluse](https://discuss.dgraph.io/u/catherineluse)\
**Post date:** [November 3, 2020, 7:02pm UTC](https://discuss.dgraph.io/t/how-to-delete-objects-based-on-nested-objects-fields/11275/3 "2020-11-03T19:02:43Z")

</div>

Ah ok, thank you.
