ash_graphql/test/support/resources/double_rel_recursive.ex

51 lines
1.2 KiB
Elixir
Raw Normal View History

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
actions do
defaults([:create, :read, :update, :destroy])
end
graphql do
type :double_rel_recursive
end
relationships do
belongs_to :double_rel, DoubleRelToRecursiveParentOfEmbed do
2022-08-31 13:08:16 +12:00
source_attribute(:double_rel_id)
2022-09-15 04:46:12 +12:00
allow_nil?(false)
end
belongs_to :myself, DoubleRelRecursive do
2022-08-31 13:08:16 +12:00
source_attribute(:recursive_id)
2022-09-15 04:46:12 +12:00
allow_nil?(false)
2022-04-27 03:35:09 +12:00
private?(true)
end
has_many :first_rel, DoubleRelRecursive do
2022-08-31 13:08:16 +12:00
destination_attribute(:recursive_id)
2022-04-27 03:35:09 +12:00
filter(expr(type == :first))
end
has_many :second_rel, DoubleRelRecursive do
2022-08-31 13:08:16 +12:00
destination_attribute(:recursive_id)
2022-04-27 03:35:09 +12:00
filter(expr(type == :second))
end
end
end