Packages
ash_json_api
0.34.0
1.7.1
1.7.0
1.6.6
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0-rc.2
1.6.0-rc.1
1.6.0-rc.0
1.5.1
1.5.0
1.4.45
1.4.44
1.4.43
1.4.42
1.4.41
1.4.40
1.4.39
1.4.38
1.4.37
1.4.36
1.4.35
1.4.34
1.4.33
1.4.32
1.4.31
1.4.30
1.4.29
1.4.28
1.4.27
1.4.26
1.4.25
1.4.24
1.4.23
1.4.22
1.4.21
1.4.20
1.4.19
1.4.18
1.4.17
1.4.16
1.4.15
1.4.13
1.4.12
1.4.11
1.4.10
1.4.9
1.4.8
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.8
1.3.7
1.3.6
1.3.5
1.3.4
retired
1.3.3
1.3.2
1.3.1
1.3.0
1.2.2
1.2.1
1.2.0
1.1.2
1.1.1
1.1.0
1.0.0
1.0.0-rc.6
1.0.0-rc.5
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
1.0.0-rc.0
0.34.2
0.34.1
0.34.0
0.33.1
0.33.0
0.32.1
0.32.0
0.31.3
0.31.2
retired
0.31.1
0.31.0
0.30.1
0.30.0-rc.4
0.30.0-rc.3
0.30.0-rc.2
0.30.0-rc.1
0.30.0-rc.0
0.29.1
0.29.0
0.28.6
0.28.5
0.28.4
0.28.3
0.28.2
0.28.1
0.28.0
0.27.6
0.27.5
0.27.1
0.27.0
0.25.0
0.24.4
0.24.2
0.24.1
0.24.0
0.23.0
0.22.0
0.21.0
0.20.0
0.19.0
0.18.0
0.17.0
0.16.0
0.15.0
0.14.0
0.13.0
0.12.0
0.11.1
0.10.0
0.9.0
0.8.0
0.6.0
0.5.0
0.4.0
0.3.0
0.2.4
0.2.3
0.2.1
0.2.0
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
The JSON:API extension for the Ash Framework.
Current section
Files
Jump to
Current section
Files
documentation/dsls/DSL:-AshJsonApi.Resource.cheatmd
<!--
This file was generated by Spark. Do not edit it by hand.
-->
# DSL: AshJsonApi.Resource
The entrypoint for adding JSON:API behavior to a resource"
## json_api
Configure the resource's behavior in the JSON:API
### Nested DSLs
* [routes](#json_api-routes)
* get
* index
* post
* patch
* delete
* related
* relationship
* post_to_relationship
* patch_relationship
* delete_from_relationship
* [primary_key](#json_api-primary_key)
### Examples
```
json_api do
type "post"
includes [
friends: [
:comments
],
comments: []
]
routes do
base "/posts"
get :read
get :me, route: "/me"
index :read
post :confirm_name, route: "/confirm_name"
patch :update
related :comments, :read
relationship :comments, :read
post_to_relationship :comments
patch_relationship :comments
delete_from_relationship :comments
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="json_api-type" href="#json_api-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">String.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The resource identifier type of this resource in JSON:API
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="json_api-includes" href="#json_api-includes">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
includes
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">`any`</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
A keyword list of all paths that are includable from this resource
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="json_api-include_nil_values?" href="#json_api-include_nil_values?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
include_nil_values?
</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>
Whether or not to include properties for values that are nil in the JSON output
</td>
</tr>
</tbody>
</table>
## json_api.routes
Configure the routes that will be exposed via the JSON:API
### Nested DSLs
* [get](#json_api-routes-get)
* [index](#json_api-routes-index)
* [post](#json_api-routes-post)
* [patch](#json_api-routes-patch)
* [delete](#json_api-routes-delete)
* [related](#json_api-routes-related)
* [relationship](#json_api-routes-relationship)
* [post_to_relationship](#json_api-routes-post_to_relationship)
* [patch_relationship](#json_api-routes-patch_relationship)
* [delete_from_relationship](#json_api-routes-delete_from_relationship)
### Examples
```
routes do
base "/posts"
get :read
get :me, route: "/me"
index :read
post :confirm_name, route: "/confirm_name"
patch :update
related :comments, :read
relationship :comments, :read
post_to_relationship :comments
patch_relationship :comments
delete_from_relationship :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="json_api-routes-base" href="#json_api-routes-base">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
base
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The base route for the resource, e.g `"/users"`
</td>
</tr>
</tbody>
</table>
## json_api.routes.get
```elixir
get action
```
A GET route to retrieve a single record
### Examples
```
get :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="action-action" href="#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 call when this route is hit
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-route" href="#action-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
<code class="inline">"/:id"</code>
</td>
<td style="text-align: left" colspan=2>
The path of the route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-default_fields" href="#action-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-primary?" href="#action-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.index
```elixir
index action
```
A GET route to retrieve a list of records
### Examples
```
index :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="action-action" href="#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 call when this route is hit
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-paginate?" href="#action-paginate?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
paginate?
</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>
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-route" href="#action-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</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>
The path of the route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-default_fields" href="#action-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-primary?" href="#action-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.post
```elixir
post action
```
A POST route to create a record
### Examples
```
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="action-action" href="#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 call when this route is hit
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-route" href="#action-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</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>
The path of the route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-default_fields" href="#action-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-primary?" href="#action-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-relationship_arguments" href="#action-relationship_arguments">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relationship_arguments
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">list(atom | {:id, atom})</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
Arguments to be used to edit relationships. See the [relationships guide](/documentation/topics/relationships.md) for more.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-upsert?" href="#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="action-upsert_identity" href="#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>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.patch
```elixir
patch action
```
A PATCH route to update a record
### Examples
```
patch :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="action-action" href="#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 call when this route is hit
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-relationship_arguments" href="#action-relationship_arguments">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relationship_arguments
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">`any`</code>
</td>
<td style="text-align: left">
<code class="inline">[]</code>
</td>
<td style="text-align: left" colspan=2>
Arguments to be used to edit relationships. See the [relationships guide](/documentation/topics/relationships.md) for more.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-read_action" href="#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 look the record up before updating
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-route" href="#action-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
<code class="inline">"/:id"</code>
</td>
<td style="text-align: left" colspan=2>
The path of the route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-default_fields" href="#action-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-primary?" href="#action-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.delete
```elixir
delete action
```
A DELETE route to destroy a record
### Examples
```
delete :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="action-action" href="#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 call when this route is hit
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-read_action" href="#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 look the record up before updating
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-route" href="#action-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
<code class="inline">"/:id"</code>
</td>
<td style="text-align: left" colspan=2>
The path of the route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-default_fields" href="#action-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="action-primary?" href="#action-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.related
```elixir
related relationship, action
```
A GET route to read the related resources of a relationship
### Examples
```
related :comments, :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="relationship-action-relationship" href="#relationship-action-relationship">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relationship
</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>
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-action-action" href="#relationship-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 call when this route is hit
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-action-route" href="#relationship-action-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The path of the route - Defaults to /:id/[relationship_name]
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-action-default_fields" href="#relationship-action-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-action-primary?" href="#relationship-action-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.relationship
```elixir
relationship relationship, action
```
A READ route to read the relationship, returns resource identifiers.
### Examples
```
relationship :comments, :read
```
### 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="relationship-action-relationship" href="#relationship-action-relationship">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relationship
</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>
</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="relationship-action-action" href="#relationship-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 call when this route is hit
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-action-route" href="#relationship-action-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The path of the route - Defaults to /:id/relationships/[relationship_name]
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-action-default_fields" href="#relationship-action-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-action-primary?" href="#relationship-action-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.post_to_relationship
```elixir
post_to_relationship relationship
```
A POST route to create related entities using resource identifiers
### Examples
```
post_to_relationship :comments
```
### 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="relationship-relationship" href="#relationship-relationship">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relationship
</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>
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-route" href="#relationship-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The path of the route - Defaults to /:id/relationships/[relationship_name]
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-default_fields" href="#relationship-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-primary?" href="#relationship-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.patch_relationship
```elixir
patch_relationship relationship
```
A PATCH route to update a relationship using resource identifiers
### Examples
```
patch_relationship :comments
```
### 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="relationship-relationship" href="#relationship-relationship">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relationship
</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>
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-route" href="#relationship-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The path of the route - Defaults to /:id/relationships/[relationship_name]
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-default_fields" href="#relationship-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-primary?" href="#relationship-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.routes.delete_from_relationship
```elixir
delete_from_relationship relationship
```
A DELETE route to remove related entities using resource identifiers
### Examples
```
delete_from_relationship :comments
```
### 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="relationship-relationship" href="#relationship-relationship">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
relationship
</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>
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-route" href="#relationship-route">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
route
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">String.t</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The path of the route - Defaults to /:id/relationships/[relationship_name]
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-default_fields" href="#relationship-default_fields">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
default_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 to be shown in the attributes of the called route
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="relationship-primary?" href="#relationship-primary?">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
primary?
</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 this is the route that should be linked to by default when rendering links to this type of route
</td>
</tr>
</tbody>
</table>
### Introspection
Target: `AshJsonApi.Resource.Route`
## json_api.primary_key
Encode the id of the JSON API response from selected attributes of a resource
### Examples
```
primary_key do
keys [:first_name, :last_name]
delimiter "~"
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="json_api-primary_key-keys" href="#json_api-primary_key-keys">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
keys
</span>
</a>
<sup style="color: red">*</sup>
</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>
the list of attributes to encode JSON API primary key
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="json_api-primary_key-delimiter" href="#json_api-primary_key-delimiter">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
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>
The delimiter to concatenate the primary key values. Default to be '-'
</td>
</tr>
</tbody>
</table>