AshAge.Changes.CreateEdge (AshAge v1.0.0)

Copy Markdown View Source

Ash change that persists a graph edge from the action's record to a destination record named by an argument, after the vertex write, inside the action's transaction.

change {AshAge.Changes.CreateEdge, edge: :author, to: :author_id}

edge: names an edge entry in the resource's age do ... end block. to: names an action argument holding the destination primary key (or a list of keys -> N edges). Edge property values come from same-named action arguments (per the edge's properties [...]). A failed or 0-row edge write returns {:error, _} so Ash rolls the vertex back; DB errors are redacted.

Each edge property MUST correspond to a same-named DECLARED action argument: that argument's declared type governs serialization exactly as a vertex attribute's type does (binary -> $age64$-tagged, datetime/date -> ISO8601). A value set on an UNDECLARED argument has no type and is stored untagged, so only declared property arguments are supported.

A nil or empty to: argument writes NO edge and the action still succeeds (the edge is optional). Make to: required at the call site to force one. Exception: the sensitive-property guard (runtime half of ValidateSensitive R4) fails the action even with an empty to: — the misdeclaration (a classified datum handed to a plaintext/undeclared argument) exists regardless of whether an edge would be written, matching the compile half's declaration-level semantics.