mirror of
https://github.com/ash-project/ash_graphql.git
synced 2024-09-21 05:43:28 +12:00
50 lines
1.2 KiB
Elixir
50 lines
1.2 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
|
|
|
|
actions do
|
|
defaults([:create, :read, :update, :destroy])
|
|
end
|
|
|
|
graphql do
|
|
type :double_rel_recursive
|
|
end
|
|
|
|
relationships do
|
|
belongs_to :double_rel, DoubleRelToRecursiveParentOfEmbed do
|
|
source_attribute(:double_rel_id)
|
|
allow_nil?(false)
|
|
end
|
|
|
|
belongs_to :myself, DoubleRelRecursive do
|
|
source_attribute(:recursive_id)
|
|
allow_nil?(false)
|
|
private?(true)
|
|
end
|
|
|
|
has_many :first_rel, DoubleRelRecursive do
|
|
destination_attribute(:recursive_id)
|
|
filter(expr(type == :first))
|
|
end
|
|
|
|
has_many :second_rel, DoubleRelRecursive do
|
|
destination_attribute(:recursive_id)
|
|
filter(expr(type == :second))
|
|
end
|
|
end
|
|
end
|