AshGraphql.Resource (ash_graphql v0.15.0) View Source
This Ash resource extension adds configuration for exposing a resource in a graphql.
Table of Contents
- graphql
- queries
- get
- read_one
- list
- mutations
- create
- update
- destroy
- queries
graphql
Configuration for a given resource in graphql
Examples:
graphql do
type :post
queries do
get :get_post, :read
list :list_posts, :read
end
mutations do
create :create_post, :create
update :update_post, :update
destroy :destroy_post, :destroy
end
end
:type
- Required. The type to use for this entity in the graphql schema:primary_key_delimiter
- If a composite primary key exists, this must be set to determine theid
field value
queries
Queries (read actions) to expose for the resource.
Examples:
queries do
get :get_post, :read
read_one :current_user, :current_user
list :list_posts, :read
end
get
A query to fetch a record by primary key
Introspection Target:
Examples:
get :get_post, :read
:name
- The name to use for the query. The default value is:get
.:action
- Required. The action to use for the query.:identity
- false The identity to use for looking up the user:allow_nil?
- Whether or not the action can return nil. The default value istrue
.
read_one
A query to fetch a record
Introspection Target:
Examples:
read_one :current_user, :current_user
:name
- The name to use for the query. The default value is:read_one
.:action
- Required. The action to use for the query.:allow_nil?
- Whether or not the action can return nil. The default value istrue
.
list
A query to fetch a list of records
Introspection Target:
Examples:
list :list_posts, :read
:name
- The name to use for the query. The default value is:list
.:action
- Required. The action to use for the query.
mutations
Mutations (create/update/destroy actions) to expose for the resource.
Examples:
mutations do
create :create_post, :create
update :update_post, :update
destroy :destroy_post, :destroy
end
create
A mutation to create a record
Introspection Target:
Examples:
create :create_post, :create
:name
- The name to use for the mutation. The default value is:get
.:action
- Required. The action to use for the mutation.
update
A mutation to update a record
Introspection Target:
Examples:
update :update_post, :update
:name
- The name to use for the mutation. The default value is:get
.:action
- Required. The action to use for the mutation.:identity
- The identity to use to fetch the record to be updated.
destroy
A mutation to destroy a record
Introspection Target:
Examples:
destroy :destroy_post, :destroy
:name
- The name to use for the mutation. The default value is:get
.:action
- Required. The action to use for the mutation.:identity
- The identity to use to fetch the record to be destroyed.