Skip to content

Mutations

Terminal window
curl -X POST "http://localhost:8080/mutate?commitNow=true" \
-H "Content-Type: application/json" \
-d '{
"set": [
{
"dgraph.type": "Dog",
"name": "Rex",
"breed": "Golden Retriever",
"hasOwner": { "dgraph.type": "Person", "name": "Alice" }
}
]
}'

The materializer automatically:

  • Adds Mammal and Animal types to Rex
  • Adds Person type ancestors to Alice
  • Creates isOwnerOf edge from Alice to Rex (if inverseOf is declared)
  • Infers domain/range types from the hasOwner property
Terminal window
curl -X POST "http://localhost:8080/mutate?commitNow=true" \
-H "Content-Type: application/json" \
-d '{
"set": [{ "uid": "0x1", "breed": "Labrador" }]
}'
Terminal window
# Delete a specific predicate
curl -X POST "http://localhost:8080/mutate?commitNow=true" \
-H "Content-Type: application/json" \
-d '{
"delete": [{ "uid": "0x1", "breed": null }]
}'
# Delete a type (triggers cascade removal of ancestor types)
curl -X POST "http://localhost:8080/mutate?commitNow=true" \
-H "Content-Type: application/json" \
-d '{
"delete": [{ "uid": "0x1", "dgraph.type": "Dog" }]
}'
Terminal window
curl -X POST "http://localhost:8080/mutate?commitNow=true" \
-H "Content-Type: application/rdf" \
-d '
_:rex <dgraph.type> "Dog" .
_:rex <name> "Rex" .
_:rex <hasOwner> _:alice .
_:alice <dgraph.type> "Person" .
_:alice <name> "Alice" .
'

Use _:label for new nodes. The response returns the assigned UIDs:

{
"data": {
"uids": {
"rex": "0x1",
"alice": "0x2"
}
}
}

If a mutation would result in a disjoint type violation, the entire mutation is rejected:

{
"errors": [{
"message": "owl/materializer: disjointness violation on entity 0x1: type \"Dog\" is disjoint with type \"Cat\""
}]
}

Mutations that would generate more than 10,000 inferred edges are rejected to prevent runaway inference.