mirror of
https://github.com/ash-project/ash_graphql.git
synced 2024-09-20 21:32:59 +12:00
47 lines
839 B
Elixir
47 lines
839 B
Elixir
defmodule AshGraphql.Test.User do
|
|
@moduledoc false
|
|
|
|
use Ash.Resource,
|
|
data_layer: Ash.DataLayer.Ets,
|
|
authorizers: [Ash.Policy.Authorizer],
|
|
extensions: [AshGraphql.Resource]
|
|
|
|
graphql do
|
|
type :user
|
|
|
|
queries do
|
|
read_one :current_user, :current_user, allow_nil?: false
|
|
end
|
|
|
|
mutations do
|
|
create :create_user, :create
|
|
# update :update_user, :update
|
|
end
|
|
end
|
|
|
|
actions do
|
|
defaults([:create, :update, :destroy, :read])
|
|
|
|
create(:create_policies)
|
|
|
|
read :current_user do
|
|
filter(id: actor(:id))
|
|
end
|
|
end
|
|
|
|
attributes do
|
|
uuid_primary_key(:id)
|
|
|
|
attribute(:name, :string)
|
|
end
|
|
|
|
policies do
|
|
policy action_type(:create) do
|
|
actor_attribute_equals(:name, "My Name")
|
|
end
|
|
|
|
policy action_type(:read) do
|
|
authorize_if(always())
|
|
end
|
|
end
|
|
end
|