Description
There is no general-purpose way to read a base field from the target instance of a DefinedSimpleRelationship filtered by alias. Resources that need to surface such a field must write bespoke calculation modules, repeating the same forward-traversal logic each time.
This is the forward-relationship counterpart to FieldViaAssignedRelationship (#156), which traverses AssignmentRelationship in the reverse direction. Together they cover the two primary aliased traversal forms in the diffo graph.
What we need
A calculation module Diffo.Provider.Calculations.FieldViaAliasedRelationship with arguments mirroring inherited_place / inherited_party:
alias: — the alias to filter on, matching DefinedSimpleRelationship records where source_id = current.id, alias = step. Optional — when omitted, traverses all outgoing DefinedSimpleRelationship records.
field: — the field name to read from the resolved target instance.
Returns a list of field values.
# Aliased — field from the target of the :provides relationship
calculate :provider_name, :string,
{Diffo.Provider.Calculations.FieldViaAliasedRelationship, [alias: :provides, field: :name]}
# Unaliased — field from all directly related targets
calculate :related_names, {:array, :string},
{Diffo.Provider.Calculations.FieldViaAliasedRelationship, [field: :name]}
Why it matters
Both aliased traversal forms — via assignment and via named relationship — are needed for the demo. FieldViaAssignedRelationship covers the reverse (consumer reading from provider); FieldViaAliasedRelationship covers the forward (provider reading from its targets). Both are required this release.
Description
There is no general-purpose way to read a base field from the target instance of a
DefinedSimpleRelationshipfiltered by alias. Resources that need to surface such a field must write bespoke calculation modules, repeating the same forward-traversal logic each time.This is the forward-relationship counterpart to
FieldViaAssignedRelationship(#156), which traversesAssignmentRelationshipin the reverse direction. Together they cover the two primary aliased traversal forms in the diffo graph.What we need
A calculation module
Diffo.Provider.Calculations.FieldViaAliasedRelationshipwith arguments mirroringinherited_place/inherited_party:alias:— the alias to filter on, matchingDefinedSimpleRelationshiprecords wheresource_id = current.id, alias = step. Optional — when omitted, traverses all outgoingDefinedSimpleRelationshiprecords.field:— the field name to read from the resolved target instance.Returns a list of field values.
Why it matters
Both aliased traversal forms — via assignment and via named relationship — are needed for the demo.
FieldViaAssignedRelationshipcovers the reverse (consumer reading from provider);FieldViaAliasedRelationshipcovers the forward (provider reading from its targets). Both are required this release.