ash_graphql/test/support/resources/post.ex
Zach Daniel fbfdb7faf8 feat: update to latest ash
feat: support query arguments
2021-01-21 23:06:06 -05:00

53 lines
917 B
Elixir

defmodule AshGraphql.Test.Post do
@moduledoc false
use Ash.Resource,
data_layer: Ash.DataLayer.Ets,
extensions: [AshGraphql.Resource]
graphql do
type :post
queries do
get :get_post, :read
list :post_library, :library
end
mutations do
create :create_post, :create_confirm
end
end
actions do
create :create do
primary?(true)
end
create :create_confirm do
argument(:confirmation, :string)
validate(confirm(:text, :confirmation))
end
read(:read, primary?: true)
read :library do
argument(:published, :boolean, default: true)
filter(
expr do
published == ^arg(:published)
end
)
end
update(:update)
destroy(:destroy)
end
attributes do
uuid_primary_key(:id)
attribute(:text, :string)
attribute(:published, :boolean, default: false)
end
end