We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.

It is possible to drop all data from your Dgraph backend, and start fresh while retaining the same endpoint.

Be careful, as this operation isn’t reversible, and all data is lost. It is highly recommended that you export your data before you drop your data.

Dropping data programmatically

You can drop data by invoking the dropData mutation on /admin/slash endpoint.

As an example, if your GraphQL endpoint is https://<your-backend>/graphql, then the admin endpoint for schema is at https://<your-backend>/admin/slash.

This endpoint requires authentication.

Here is curl example.

curl 'https://<your-backend>/admin/slash' \
  -H 'X-Auth-Token: <your-token>' \
  -H 'Content-Type: application/graphql' \
  --data-binary 'mutation { dropData(allData: true) { response { code message } } }'

If you would like to drop the schema along with the data, then you can set the allDataAndSchema flag.

curl 'https://<your-backend>/admin/slash' \
  -H 'X-Auth-Token: <your-token>' \
  -H 'Content-Type: application/graphql' \
  --data-binary 'mutation { dropData(allDataAndSchema: true) { response { code message } } }'

Self-managed

Drop data and schema

The /alter endpoint is used to drop data.

To drop all data and schema:

curl -X POST localhost:8080/alter -d '{"drop_all": true}'

To drop all data only (keep schema):

curl -X POST localhost:8080/alter -d '{"drop_op": "DATA"}'

The /alter endpoint can also be used to drop a specific property or all nodes of a specific type.

To drop property name:

curl -X POST localhost:8080/alter -d '{"drop_attr": "name"}'

To drop the type Film:

curl -X POST localhost:8080/alter -d '{"drop_op": "TYPE", "drop_value": "Film"}'