2023-06-16 02:36:20 +12:00
|
|
|
defmodule AshGraphql.Test.SponsoredComment do
|
|
|
|
@moduledoc false
|
|
|
|
|
|
|
|
use Ash.Resource,
|
2024-04-02 07:03:06 +13:00
|
|
|
domain: AshGraphql.Test.Domain,
|
2023-06-16 02:36:20 +12:00
|
|
|
data_layer: Ash.DataLayer.Ets,
|
|
|
|
extensions: [AshGraphql.Resource]
|
|
|
|
|
|
|
|
graphql do
|
|
|
|
type :sponsored_comment
|
|
|
|
|
|
|
|
queries do
|
|
|
|
get :get_sponsored_comment, :read
|
|
|
|
end
|
|
|
|
|
|
|
|
mutations do
|
|
|
|
create :create_sponsored_comment, :create
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
actions do
|
2024-04-02 07:03:06 +13:00
|
|
|
default_accept(:*)
|
2023-06-16 02:36:20 +12:00
|
|
|
defaults([:create, :update, :destroy])
|
|
|
|
|
|
|
|
read :read do
|
|
|
|
primary?(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
read :paginated do
|
|
|
|
pagination(required?: true, offset?: true, countable: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
attributes do
|
|
|
|
uuid_primary_key(:id)
|
2024-04-02 07:03:06 +13:00
|
|
|
attribute(:text, :string, public?: true)
|
2023-06-16 02:36:20 +12:00
|
|
|
|
|
|
|
attribute :type, :atom do
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2023-06-16 02:36:20 +12:00
|
|
|
writable?(false)
|
|
|
|
default(:sponsored)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
relationships do
|
2024-04-02 07:03:06 +13:00
|
|
|
belongs_to(:post, AshGraphql.Test.Post, public?: true)
|
2023-06-16 02:36:20 +12:00
|
|
|
end
|
|
|
|
end
|