You are looking at the docs for an older version of Dgraph (v21.03). The latest version is v24.0.
Ask a Question

Delete Mutations

Delete Mutations allow 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 types in the schema for the delete mutation. Delete mutations take 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.