graph

ontology.define_link_type

Define a graph link type.

strata graph ontology define-link-type

wire graph_define_link_type

Declares a link type in the graph's ontology: a name, its source and target object types, an optional cardinality hint (for example `many-to-one`), and property definitions. Source and target must name declared object types by the time the ontology is frozen. After freezing, 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-link-type --help

Example

Define a link (edge) type between two object types.

strata graph create gcreated graph gstrata graph ontology define-object-type g personcreated object type person in gstrata graph ontology define-link-type g knows person personcreated link type knows in gstrata graph ontology get ggraph         gstatus        draftversion       …object_types  NAME    PROPERTIES  person  -link_types  CARDINALITY  NAME   PROPERTIES  SOURCE  TARGET  -            knows  -           person  person

Parameters

NameTypeRequiredDescription
graphstringyesGraph name.
namestringyesLink type name.
sourcestringyesDeclared source object type.
targetstringyesDeclared target object type.
branchstring or nullnoTarget branch. Defaults to the executor handle branch.
cardinalitystring or nullnoOptional cardinality: one of `one-to-one`, `one-to-many`, `many-to-one`, or `many-to-many`. Unknown values are rejected.
propertiesobjectnoDeclared properties by name.
spacestring or nullnoTarget product space. Defaults to `"default"`.

Returns

MutationAck

  • dataobject
  • typestring

Errors

Recover by code. Retry policy and commit outcome come from the shipped error registry.

← All 31 Graph commands

agents: this page as markdown → /docs/reference/graph/ontology/define_link_type.md