Mutations
JSON Mutations
Section titled “JSON Mutations”Insert
Section titled “Insert”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
MammalandAnimaltypes to Rex - Adds
Persontype ancestors to Alice - Creates
isOwnerOfedge from Alice to Rex (ifinverseOfis declared) - Infers domain/range types from the
hasOwnerproperty
Update
Section titled “Update”curl -X POST "http://localhost:8080/mutate?commitNow=true" \ -H "Content-Type: application/json" \ -d '{ "set": [{ "uid": "0x1", "breed": "Labrador" }] }'Delete
Section titled “Delete”# Delete a specific predicatecurl -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" }] }'RDF Mutations
Section titled “RDF Mutations”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" . 'Blank Nodes
Section titled “Blank Nodes”Use _:label for new nodes. The response returns the assigned UIDs:
{ "data": { "uids": { "rex": "0x1", "alice": "0x2" } }}Disjointness Errors
Section titled “Disjointness Errors”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\"" }]}Circuit Breaker
Section titled “Circuit Breaker”Mutations that would generate more than 10,000 inferred edges are rejected to prevent runaway inference.