ash_graphql/test/support/resources/double_rel_recursive.ex
Zach Daniel 553152abef
test: added some test resources to reproduce an issue with duplicated Graph… (#30)
Co-authored-by: Simon Bergström <simon@menuan.se>
2022-03-24 21:20:01 -04:00

46 lines
1.1 KiB
Elixir

defmodule AshGraphql.Test.DoubleRelRecursive do
@moduledoc false
use Ash.Resource,
data_layer: Ash.DataLayer.Ets,
extensions: [AshGraphql.Resource]
alias AshGraphql.Test.DoubleRelEmbed
alias AshGraphql.Test.DoubleRelRecursive
alias AshGraphql.Test.DoubleRelToRecursiveParentOfEmbed
alias AshGraphql.Test.DoubleRelType
attributes do
uuid_primary_key(:id)
attribute(:type, DoubleRelType, allow_nil?: true)
attribute(:this, :string, allow_nil?: true)
attribute(:or_that, DoubleRelEmbed, allow_nil?: true)
end
graphql do
type :double_rel_recursive
end
relationships do
belongs_to :double_rel, DoubleRelToRecursiveParentOfEmbed do
source_field :double_rel_id
required? true
end
belongs_to :myself, DoubleRelRecursive do
source_field :recursive_id
required? false
private? true
end
has_many :first_rel, DoubleRelRecursive do
destination_field :recursive_id
filter expr(type == :first)
end
has_many :second_rel, DoubleRelRecursive do
destination_field :recursive_id
filter expr(type == :second)
end
end
end