2022-03-25 14:20:01 +13:00
|
|
|
defmodule AshGraphql.Test.DoubleRelRecursive do
|
|
|
|
@moduledoc false
|
|
|
|
|
|
|
|
use Ash.Resource,
|
2024-04-02 07:03:06 +13:00
|
|
|
domain: AshGraphql.Test.Domain,
|
2022-03-25 14:20:01 +13:00
|
|
|
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)
|
2024-04-02 07:03:06 +13:00
|
|
|
attribute(:type, DoubleRelType, allow_nil?: true, public?: true)
|
|
|
|
attribute(:this, :string, allow_nil?: true, public?: true)
|
|
|
|
attribute(:or_that, DoubleRelEmbed, allow_nil?: true, public?: true)
|
2022-03-25 14:20:01 +13:00
|
|
|
end
|
|
|
|
|
2022-05-18 04:30:19 +12:00
|
|
|
actions do
|
2024-04-02 07:03:06 +13:00
|
|
|
default_accept(:*)
|
2022-05-18 04:30:19 +12:00
|
|
|
defaults([:create, :read, :update, :destroy])
|
|
|
|
end
|
|
|
|
|
2022-03-25 14:20:01 +13:00
|
|
|
graphql do
|
|
|
|
type :double_rel_recursive
|
|
|
|
end
|
|
|
|
|
|
|
|
relationships do
|
|
|
|
belongs_to :double_rel, DoubleRelToRecursiveParentOfEmbed do
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2022-08-31 13:08:16 +12:00
|
|
|
source_attribute(:double_rel_id)
|
2022-09-15 04:46:12 +12:00
|
|
|
allow_nil?(false)
|
2022-03-25 14:20:01 +13:00
|
|
|
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)
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2022-03-25 14:20:01 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
has_many :first_rel, DoubleRelRecursive do
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2022-08-31 13:08:16 +12:00
|
|
|
destination_attribute(:recursive_id)
|
2022-04-27 03:35:09 +12:00
|
|
|
filter(expr(type == :first))
|
2022-03-25 14:20:01 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
has_many :second_rel, DoubleRelRecursive do
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2022-08-31 13:08:16 +12:00
|
|
|
destination_attribute(:recursive_id)
|
2022-04-27 03:35:09 +12:00
|
|
|
filter(expr(type == :second))
|
2022-03-25 14:20:01 +13:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|