Packages
ash_graphql
0.26.6
1.10.0
1.9.4
1.9.3
1.9.2
1.9.1
1.9.0
1.8.5
1.8.4
1.8.3
1.8.2
1.8.1
1.8.0
1.7.17
1.7.16
1.7.15
1.7.14
1.7.13
1.7.12
1.7.11
1.7.10
1.7.9
1.7.8
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.6.0
1.5.1
1.5.0
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc.5
1.0.0-rc.4
retired
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
1.0.0-rc.0
0.28.1
0.28.0
0.27.1
0.27.0
0.26.9
0.26.8
0.26.7
0.26.6
0.26.5
0.26.4
0.26.3
0.26.2
0.26.0
0.25.13
0.25.12
0.25.10
0.25.9
0.25.8
0.25.7
0.25.6
0.25.5
0.25.4
0.25.3
0.25.2
0.25.1
0.25.0
0.24.1
0.24.0
0.23.3
0.23.2
0.23.1
0.23.0
0.22.13
0.22.12
0.22.11
0.22.10
0.22.9
0.22.8
0.22.7
0.22.6
0.22.4
0.22.3
0.22.2
0.22.1
0.22.0
0.21.0
retired
0.20.5
0.20.4
0.20.3
0.20.2
0.20.1
0.20.0-rc.3
0.20.0-rc.2
0.20.0-rc.1
0.20.0-rc.0
0.19.0
0.18.0-rc0
0.17.5
0.17.5-rc0
0.17.4
0.17.2
0.17.1
0.17.0
0.16.28
0.16.27
0.16.26
0.16.25
0.16.24
0.16.23
0.16.22
0.16.21
0.16.20
0.16.18-rc5
0.16.18-rc4
0.16.18-rc3
0.16.18-rc2
0.16.18-rc1
0.16.18-rc0
0.16.17
0.16.16
0.16.15
0.16.14
0.16.13
0.16.12
0.16.11
0.16.10
0.16.9
0.16.8
0.16.7
0.16.6
0.16.5
0.16.4
0.16.3
0.16.2
0.16.1
0.16.0
0.15.10
0.15.9
0.15.8
0.15.7
0.15.6
0.15.5
0.15.4
0.15.3
0.15.2
0.15.1
0.15.0
0.14.1
0.14.0
0.13.1
0.13.0
0.12.5
0.12.4
0.12.3
0.12.1
0.12.0
0.10.0
0.9.5
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.0
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.3
0.6.2
0.6.1
0.6.0
0.5.0
0.4.0
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.3
0.1.2
The extension for building GraphQL APIs with Ash
Current section
Files
Jump to
Current section
Files
documentation/dsls/DSL:-AshGraphql.Resource.cheatmd
<!--
This file was generated by Spark. Do not edit it by hand.
-->
# DSL: AshGraphql.Resource
This Ash resource extension adds configuration for exposing a resource in a graphql.
## graphql
Configuration for a given resource in graphql
### Nested DSLs
* [queries](#graphql-queries)
* get
* read_one
* list
* action
* [mutations](#graphql-mutations)
* create
* update
* destroy
* action
* [managed_relationships](#graphql-managed_relationships)
* managed_relationship
### 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
```
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="graphql-type" href="#graphql-type">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
type
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The type to use for this entity in the graphql schema
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-derive_filter?" href="#graphql-derive_filter?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
derive_filter?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">true</code>
</td>
<td style="text-align: left" colspan=2>
Set to false to disable the automatic generation of a filter input for read actions.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-derive_sort?" href="#graphql-derive_sort?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
derive_sort?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">true</code>
</td>
<td style="text-align: left" colspan=2>
Set to false to disable the automatic generation of a sort input for read actions.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-encode_primary_key?" href="#graphql-encode_primary_key?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
encode_primary_key?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">true</code>
</td>
<td style="text-align: left" colspan=2>
For resources with composite primary keys, or primary keys not called `:id`, this will cause the id to be encoded as a single `id` attribute, both in the representation of the resource and in get requests
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-relationships" href="#graphql-relationships">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relationships
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">list(atom)</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A list of relationships to include on the created type. Defaults to all public relationships where the destination defines a graphql type.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-field_names" href="#graphql-field_names">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
field_names
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A keyword list of name overrides for attributes.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-hide_fields" href="#graphql-hide_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
hide_fields
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">list(atom)</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A list of attributes to hide from the api
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-argument_names" href="#graphql-argument_names">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
argument_names
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A nested keyword list of action names, to argument name remappings. i.e `create: [arg_name: :new_name]`
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-keyset_field" href="#graphql-keyset_field">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
keyset_field
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
If set, the keyset will be displayed on all read actions in this field. It will be `nil` unless at least one of the read actions on a resource uses keyset pagination or it is the result of a mutation
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-attribute_types" href="#graphql-attribute_types">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
attribute_types
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A keyword list of type overrides for attributes. The type overrides should refer to types available in the graphql (absinthe) schema. `list_of/1` and `non_null/1` helpers can be used.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-attribute_input_types" href="#graphql-attribute_input_types">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
attribute_input_types
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A keyword list of input type overrides for attributes. The type overrides should refer to types available in the graphql (absinthe) schema. `list_of/1` and `non_null/1` helpers can be used.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-primary_key_delimiter" href="#graphql-primary_key_delimiter">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary_key_delimiter
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
<code class="inline">"~"</code>
</td>
<td style="text-align: left" colspan=2>
If a composite primary key exists, this can be set to determine delimiter used in the `id` field value.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-depth_limit" href="#graphql-depth_limit">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
depth_limit
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">integer</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A simple way to prevent massive queries.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-generate_object?" href="#graphql-generate_object?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
generate_object?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">true</code>
</td>
<td style="text-align: left" colspan=2>
Whether or not to create the GraphQL object, this allows you to manually create the GraphQL object.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="graphql-filterable_fields" href="#graphql-filterable_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
filterable_fields
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">list(atom)</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A list of fields that are allowed to be filtered on. Defaults to all filterable fields for which a GraphQL type can be created.
</td>
</tr>
</tbody>
</table>
## graphql.queries
Queries (read actions) to expose for the resource.
### Nested DSLs
* [get](#graphql-queries-get)
* [read_one](#graphql-queries-read_one)
* [list](#graphql-queries-list)
* [action](#graphql-queries-action)
### Examples
```
queries do
get :get_post, :read
read_one :current_user, :current_user
list :list_posts, :read
end
```
## graphql.queries.get
```elixir
get name, action
```
A query to fetch a record by primary key
### Examples
```
get :get_post, :read
```
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-action" href="#name-action-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action to use for the query.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-identity" href="#name-action-identity">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
identity
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The identity to use for looking up the record. Pass `false` to not use an identity.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-allow_nil?" href="#name-action-allow_nil?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
allow_nil?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">true</code>
</td>
<td style="text-align: left" colspan=2>
Whether or not the action can return nil.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-modify_resolution" href="#name-action-modify_resolution">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
modify_resolution
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">mfa</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
An MFA that will be called with the resolution, the query, and the result of the action as the first three arguments. See the [the guide](/documentation/topics/modifying-the-resolution.html) for more.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-name" href="#name-action-name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:get</code>
</td>
<td style="text-align: left" colspan=2>
The name to use for the query.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-type_name" href="#name-action-type_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
type_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
Override the type name returned by this query. Must be set if the read action has `metadata` that is not hidden via the `show_metadata` key.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-metadata_names" href="#name-action-metadata_names">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
metadata_names
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
Name overrides for metadata fields on the read action.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-metadata_types" href="#name-action-metadata_types">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
metadata_types
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
Type overrides for metadata fields on the read action.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-show_metadata" href="#name-action-show_metadata">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
show_metadata
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">list(atom)</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The metadata attributes to show. Defaults to all.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-as_mutation?" href="#name-action-as_mutation?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
as_mutation?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">false</code>
</td>
<td style="text-align: left" colspan=2>
Places the query in the `mutations` key instead. Not typically necessary, but is often paired with `as_mutation?`. See the [the guide](/documentation/topics/modifying-the-resolution.html) for more.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.Query`
## graphql.queries.read_one
```elixir
read_one name, action
```
A query to fetch a record
### Examples
```
read_one :current_user, :current_user
```
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-action" href="#name-action-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action to use for the query.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-allow_nil?" href="#name-action-allow_nil?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
allow_nil?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">true</code>
</td>
<td style="text-align: left" colspan=2>
Whether or not the action can return nil.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-name" href="#name-action-name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:get</code>
</td>
<td style="text-align: left" colspan=2>
The name to use for the query.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-type_name" href="#name-action-type_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
type_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
Override the type name returned by this query. Must be set if the read action has `metadata` that is not hidden via the `show_metadata` key.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-metadata_names" href="#name-action-metadata_names">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
metadata_names
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
Name overrides for metadata fields on the read action.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-metadata_types" href="#name-action-metadata_types">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
metadata_types
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
Type overrides for metadata fields on the read action.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-show_metadata" href="#name-action-show_metadata">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
show_metadata
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">list(atom)</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The metadata attributes to show. Defaults to all.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-as_mutation?" href="#name-action-as_mutation?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
as_mutation?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">false</code>
</td>
<td style="text-align: left" colspan=2>
Places the query in the `mutations` key instead. Not typically necessary, but is often paired with `as_mutation?`. See the [the guide](/documentation/topics/modifying-the-resolution.html) for more.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.Query`
## graphql.queries.list
```elixir
list name, action
```
A query to fetch a list of records
### Examples
```
list :list_posts, :read
```
```
list :list_posts_paginated, :read, relay?: true
```
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-action" href="#name-action-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action to use for the query.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-relay?" href="#name-action-relay?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relay?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">false</code>
</td>
<td style="text-align: left" colspan=2>
If true, the graphql queries/resolvers for this resource will be built to honor the relay specification. See [the relay guide](/documentation/topics/relay.html) for more.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-name" href="#name-action-name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:get</code>
</td>
<td style="text-align: left" colspan=2>
The name to use for the query.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-type_name" href="#name-action-type_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
type_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
Override the type name returned by this query. Must be set if the read action has `metadata` that is not hidden via the `show_metadata` key.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-metadata_names" href="#name-action-metadata_names">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
metadata_names
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
Name overrides for metadata fields on the read action.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-metadata_types" href="#name-action-metadata_types">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
metadata_types
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">Keyword.t</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
Type overrides for metadata fields on the read action.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-show_metadata" href="#name-action-show_metadata">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
show_metadata
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">list(atom)</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The metadata attributes to show. Defaults to all.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-as_mutation?" href="#name-action-as_mutation?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
as_mutation?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">false</code>
</td>
<td style="text-align: left" colspan=2>
Places the query in the `mutations` key instead. Not typically necessary, but is often paired with `as_mutation?`. See the [the guide](/documentation/topics/modifying-the-resolution.html) for more.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.Query`
## graphql.queries.action
```elixir
action name, action
```
Runs a generic action
### Examples
```
action :check_status, :check_status
```
### Arguments
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-action" href="#name-action-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action to use for the query.
</td>
</tr>
</tbody>
</table>
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-name" href="#name-action-name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:get</code>
</td>
<td style="text-align: left" colspan=2>
The name to use for the query.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.Action`
## graphql.mutations
Mutations (create/update/destroy actions) to expose for the resource.
### Nested DSLs
* [create](#graphql-mutations-create)
* [update](#graphql-mutations-update)
* [destroy](#graphql-mutations-destroy)
* [action](#graphql-mutations-action)
### Examples
```
mutations do
create :create_post, :create
update :update_post, :update
destroy :destroy_post, :destroy
end
```
## graphql.mutations.create
```elixir
create name, action
```
A mutation to create a record
### Examples
```
create :create_post, :create
```
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-action" href="#name-action-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action to use for the mutation.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-name" href="#name-action-name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:get</code>
</td>
<td style="text-align: left" colspan=2>
The name to use for the mutation.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-upsert?" href="#name-action-upsert?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
upsert?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
<code class="inline">false</code>
</td>
<td style="text-align: left" colspan=2>
Whether or not to use the `upsert?: true` option when calling `YourApi.create/2`.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-upsert_identity" href="#name-action-upsert_identity">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
upsert_identity
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">false</code>
</td>
<td style="text-align: left" colspan=2>
Which identity to use for the upsert
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-modify_resolution" href="#name-action-modify_resolution">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
modify_resolution
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">mfa</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
An MFA that will be called with the resolution, the query, and the result of the action as the first three arguments. See the [the guide](/documentation/topics/modifying-the-resolution.html) for more.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.Mutation`
## graphql.mutations.update
```elixir
update name, action
```
A mutation to update a record
### Examples
```
update :update_post, :update
```
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-action" href="#name-action-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action to use for the mutation.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-name" href="#name-action-name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:get</code>
</td>
<td style="text-align: left" colspan=2>
The name to use for the mutation.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-identity" href="#name-action-identity">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
identity
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The identity to use to fetch the record to be updated. Use `false` if no identity is required.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-read_action" href="#name-action-read_action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
read_action
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The read action to use to fetch the record to be updated. Defaults to the primary read action.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.Mutation`
## graphql.mutations.destroy
```elixir
destroy name, action
```
A mutation to destroy a record
### Examples
```
destroy :destroy_post, :destroy
```
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-action" href="#name-action-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action to use for the mutation.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-name" href="#name-action-name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:get</code>
</td>
<td style="text-align: left" colspan=2>
The name to use for the mutation.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-read_action" href="#name-action-read_action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
read_action
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The read action to use to fetch the record to be destroyed. Defaults to the primary read action.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="name-action-identity" href="#name-action-identity">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
identity
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The identity to use to fetch the record to be destroyed. Use `false` if no identity is required.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.Mutation`
## graphql.mutations.action
```elixir
action name, action
```
Runs a generic action
### Examples
```
action :check_status, :check_status
```
### Arguments
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-action" href="#name-action-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action to use for the query.
</td>
</tr>
</tbody>
</table>
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="name-action-name" href="#name-action-name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:get</code>
</td>
<td style="text-align: left" colspan=2>
The name to use for the query.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.Action`
## graphql.managed_relationships
Generates input objects for `manage_relationship` arguments on resource actions.
### Nested DSLs
* [managed_relationship](#graphql-managed_relationships-managed_relationship)
### Examples
```
managed_relationships do
manage_relationship :create_post, :comments
end
```
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="graphql-managed_relationships-auto?" href="#graphql-managed_relationships-auto?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
auto?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
Automatically derive types for all arguments that have a `manage_relationship` call change.
</td>
</tr>
</tbody>
</table>
## graphql.managed_relationships.managed_relationship
```elixir
managed_relationship action, argument
```
Instructs ash_graphql that a given argument with a `manage_relationship` change should have its input objects derived automatically from the potential actions to be called.
For example, given an action like:
```elixir
actions do
create :create do
argument :comments, {:array, :map}
change manage_relationship(:comments, type: :direct_control) # <- we look for this change with a matching argument name
end
end
```
You could add the following managed_relationship
```elixir
graphql do
...
managed_relationships do
managed_relationship :create, :comments
end
end
```
By default, the `{:array, :map}` would simply be a `json[]` type. If the argument name
is placed in this list, all of the potential actions that could be called will be combined
into a single input object. If there are type conflicts (for example, if the input could create
or update a record, and the create and update actions have an argument of the same name but with a different type),
a warning is emitted at compile time and the first one is used. If that is insufficient, you will need to do one of the following:
1.) provide the `:types` option to the `managed_relationship` constructor (see that option for more)
2.) define a custom type, with a custom input object (see the custom types guide), and use that custom type instead of `:map`
3.) change your actions to not have overlapping inputs with different types
Since managed relationships can ultimately call multiple actions, there is the possibility
of field type conflicts. Use the `types` option to determine the type of fields and remove the conflict warnings.
For `non_null` use `{:non_null, type}`, and for a list, use `{:array, type}`, for example:
`{:non_null, {:array, {:non_null, :string}}}` for a non null list of non null strings.
To *remove* a key from the input object, simply pass `nil` as the type.
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="action-argument-argument" href="#action-argument-argument">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
argument
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The argument for which an input object should be derived.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-argument-action" href="#action-argument-action">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
action
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The action that accepts the argument
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-argument-lookup_with_primary_key?" href="#action-argument-lookup_with_primary_key?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
lookup_with_primary_key?
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">boolean</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
If the managed_relationship has `on_lookup` behavior, this option determines whether or not the primary key is provided in the input object for looking up.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-argument-lookup_identities" href="#action-argument-lookup_identities">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
lookup_identities
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">list(atom)</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
Determines which identities are provided in the input object for looking up, if there is `on_lookup` behavior. Defalts to the `use_identities` option.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-argument-type_name" href="#action-argument-type_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
type_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The name of the input object that will be derived. Defaults to `<action_type>_<resource>_<argument_name>_input`
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-argument-types" href="#action-argument-types">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
types
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">`any`</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
A keyword list of field names to their graphql type identifiers.
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshGraphql.Resource.ManagedRelationship`