You are looking at the docs for the unreleased master branch of Dgraph. The latest version is v20.11.
Report Issue Edit Page

Delete Mutations

Delete Mutations allows you to delete objects of a particular type.

We use the following schema to demonstrate some examples.


type Author {
	id: ID!
	name: String! @search(by: [hash])
	dob: DateTime
	posts: [Post]

type Post {
	postID: ID!
	title: String! @search(by: [term, fulltext])
	text: String @search(by: [fulltext, term])
	datePublished: DateTime

Dgraph automatically generates input and return type in the schema for the delete mutation. Delete Mutations takes filter as an input to select specific objects and returns the state of the objects before deletion.

deleteAuthor(filter: AuthorFilter!): DeleteAuthorPayload

type DeleteAuthorPayload {
	author(filter: AuthorFilter, order: AuthorOrder, first: Int, offset: Int): [Author]
	msg: String
	numUids: Int

Example: Delete mutation using variables

mutation deleteAuthor($filter: AuthorFilter!) {
  deleteAuthor(filter: $filter) {
    author {


{ "filter":
  { "name": { "eq": "A.N. Author" } }


You can refer to the following link for more examples.

Continue the conversation on Discuss.