Current section

Files

Jump to
ash_neo4j lib transformers transform_add_relationship_attributes.ex
Raw

lib/transformers/transform_add_relationship_attributes.ex

# SPDX-FileCopyrightText: 2025 ash_neo4j contributors <https://github.com/diffo-dev/ash_neo4j/graphs.contributors>
#
# SPDX-License-Identifier: MIT
defmodule AshNeo4j.Transformers.TransformAddRelationshipAttributes do
@moduledoc false
use Spark.Dsl.Transformer
alias Spark.Dsl.Transformer
alias Spark.Dsl.Verifier
@impl true
def transform(dsl) do
{:ok, add_relationship_attributes(dsl)}
end
defp add_relationship_attributes(dsl) do
relationships = Verifier.get_entities(dsl, [:relationships])
relationship_attributes =
Enum.into(relationships, [], fn relationship ->
{Map.get(relationship, :source_attribute), Map.get(relationship, :name)}
end)
Transformer.set_option(dsl, [:neo4j], :relationship_attributes, relationship_attributes)
end
end