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 ./my-graph \
--query mutations.gq \
--name remove_person \
--params '{"name": "Alice"}'Or via the HTTP API:
curl -X POST http://localhost:4000/change \
-H "Content-Type: application/json" \
-d '{
"uri": "./my-graph",
"query": "mutations.gq",
"name": "remove_person",
"params": {"name": "Alice"}
}'Deleting edges
Edges are deleted the same way. Use the edge type name and a where clause:
query remove_knows($person_a: String, $person_b: String) {
delete Knows where src = $person_a
}To remove a specific edge between two nodes, filter on both src and dst:
query remove_specific_edge($from: String, $to: String) {
delete WorksAt where src = $from
}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 src or dst. 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 ./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 -- for example, an internal error during cascade -- 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.