AshNeo4j.Calculations.ProjectedTraversal (AshNeo4j v0.10.0)

Copy Markdown View Source

Read-time projection of a graph traversal (#329): follows a hop chain from each record to the reached node and returns it as a value — late-binding the reached node's concrete type at read time via AshNeo4j.worlds/1.

Use it where the reached node's concrete subtype isn't known at the source resource's compile time (open-world refs across a cascade) — the read-time sibling of the traverse(^chain, …) filter expression.

Usage

calculate :site, :struct,
  {AshNeo4j.Calculations.ProjectedTraversal,
   chain: [{:forward, :place_ref}, {:forward, :place}]}

Options

  • :chain (required) — the hop chain, each hop {:forward | :reverse, edge_selector}, same grammar as the traverse/2 expression.

Result per record

  • the concrete record — a node was reached and its labels resolved to a loaded (domain, resource) world;
  • %AshNeo4j.Unknown{reason: :no_concrete_world} — a node was reached but its labels resolve to no loaded world (it can't be returned as a typed record);
  • nil — nothing was reached (genuine absence);
  • %Ash.NotLoaded{} — until the calculation is loaded.

v1 is single-valued (the first reached node) and projects the reached record; list projection and single-field projection are follow-ups.

Summary

Functions

describe(opts)

Callback implementation for Ash.Resource.Calculation.describe/1.

has_calculate?()

has_expression?()

Callback implementation for Ash.Resource.Calculation.has_expression?/0.

init(opts)

Callback implementation for Ash.Resource.Calculation.init/1.

strict_loads?()

Callback implementation for Ash.Resource.Calculation.strict_loads?/0.