Delete
Remove nodes and edges with automatic edge cascade.
The delete operation removes nodes or edges from the graph. When a node is
deleted, all edges connected to it are automatically removed as well.
Deleting nodes
Use delete TypeName where predicate to remove nodes that match a condition:
query remove_person($name: String) {
delete Person where name = $name
}omnigraph change --uri ./my-graph \
--query mutations.gq \
--name remove_person \
--params '{"name": "Alice"}'Or via the HTTP API:
curl -X POST http://localhost:8080/change \
-H "Content-Type: application/json" \
-d '{
"query_source": "query remove_person($name: String) { delete Person where name = $name }",
"query_name": "remove_person",
"params": {"name": "Alice"},
"branch": "main"
}'Deleting edges
Edges are deleted the same way. Use the edge type name and a where clause.
Edge endpoints are referenced by the reserved fields from and to:
query remove_knows_from($person: String) {
delete Knows where from = $person
}Delete mutations currently support a single predicate, so choose a property that identifies the rows you want to remove.
Where clause
The where clause supports the same operators as update:
| Operator | Meaning |
|---|---|
= | Equal |
!= | Not equal |
< | Less than |
> | Greater than |
<= | Less than or equal |
>= | Greater than or equal |
Edge cascade on node delete
When you delete a node, Omnigraph automatically removes every edge where that
node appears as either from or to. This prevents dangling references in the
graph.
For example, given this schema:
node Person {
name: String @key
}
node Company {
name: String @key
}
edge WorksAt: Person -> Company
edge Knows: Person -> PersonDeleting a Person named "Alice" removes:
- The
Personnode itself - Every
WorksAtedge where Alice is the source - Every
Knowsedge where Alice is either source or destination
No orphaned edges remain in the graph after the delete completes.
Bulk deletes
A where clause that matches multiple rows deletes all of them in a single
transaction:
query clear_completed() {
delete Task where status = "completed"
}omnigraph change --uri ./my-graph \
--query mutations.gq \
--name clear_completedThis removes every Task with status = "completed" and cascades to all edges
connected to those tasks.
Transactional safety
Delete operations are fully transactional:
- If the delete succeeds, all matching nodes and their cascaded edges are removed atomically.
- If any part of the delete fails, the entire operation is rolled back and no data is changed.
- Deletes on a branch do not affect other branches until the branch is merged.
This makes it safe to issue broad deletes on a branch, inspect the result, and discard the branch if the outcome is not what you expected.