graph
ontology.define_object_type
Define a graph object type.
strata graph ontology define-object-typedb.graphs.ontology.define_object_type(graph: 'str', name: 'str', *, properties: 'Optional[dict]' = None) -> 'Any'wire graph_define_object_type
Declares an object type in the graph's ontology: a name plus property definitions (`value_type`, `required`). While the ontology is a draft, redefining a type replaces it freely. After `graph.ontology.freeze`, the ontology is immutable and this command fails with `failed_precondition.engine.graph_ontology_frozen`.
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:
strata graph ontology define-object-type --helphelp(db.graphs.ontology.define_object_type)
Example
Define an object (node) type.
strata graph create gstrata graph ontology define-object-type g personstrata graph ontology summary g
_ = db.graphs.create("g")_ = db.graphs.ontology.define_object_type("g", "person")[o.name for o in db.graphs.ontology.summary("g").object_types]
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| graph | string | yes | Graph name. |
| name | string | yes | Object type name. |
| branch | string or null | no | Target branch. Defaults to the executor handle branch. |
| properties | object | no | Declared properties by name. |
| space | string or null | no | Target product space. Defaults to `"default"`. |
Returns
MutationAck<GraphOntologyWrite>
- 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_name | never | not_started |
| not_found.engine.graph | never | not_applicable |
| invalid_argument.engine.graph_type_name | never | not_started |
| invalid_argument.engine.graph_type_name_reserved | never | not_started |
| invalid_argument.engine.graph_property_name | never | not_started |
| failed_precondition.engine.graph_ontology_frozen | never | not_started |