graph
apply_delete_policy
Apply a delete policy to bound graph facts.
db.graphs.apply_delete_policy(primitive: 'str', key: 'str', policy: 'str', *, space: 'Optional[str]' = None) -> 'Any'wire graph_apply_delete_policy
Applies an explicit policy to every graph node bound to the given entity target: `cascade` deletes the bound nodes and their incident edges, `detach` keeps the nodes but removes their bindings, and `keep_dangling` preserves the bindings so traversal can report the target's status. The acknowledgement reports how many bound nodes the policy covered.
Successful mutations return an acknowledgement of the outcome: for a state-changing write, the affected target with the mutation effect and commit facts; for mutations that produce a domain result (such as a branch or a promotion outcome), that result object.
To see the complete help for this command, run:
help(db.graphs.apply_delete_policy)
Example
Cascade-delete graph facts bound to an entity.
_ = db.graphs.create("kb")_ = db.graphs.add_node("kb", "ada", binding={"target": {"primitive": "kv", "space": "default", "key": "user:1"}})_ = db.graphs.apply_delete_policy("kv", "user:1", "cascade") # cascade removes the bound node and its incident edges.db.graphs.get_node("kb", "ada") is None
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| policy | GraphDeletePolicy | yes | Policy to apply: `cascade`, `detach`, or `keep_dangling`.one of: cascade, detach, keep_dangling |
| target | GraphBindingTarget | yes | The bound entity target. |
| branch | string or null | no | Target branch. Defaults to the executor handle branch. |
| space | string or null | no | Target product space. Defaults to `"default"`. |
Returns
MutationAck<GraphDeletePolicyApply>
- dataobject
- typestring
Errors
Recover by code. Retry policy and commit outcome come from the shipped error registry.
| Code | Retry | Commit outcome |
|---|---|---|
| failed_precondition.engine.runtime_closed | never | not_started |
| not_found.engine.branch | never | not_applicable |
| invalid_argument.engine.product_space | never | not_started |
| invalid_argument.engine.graph_binding | never | not_started |