-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
442dc13
commit 6fedbd7
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Custom Queries & Mutations | ||
|
||
You can define your own queries and mutations in your schema, | ||
using Absinthe's tooling. See their docs for more. | ||
|
||
If you want to return resource types defined by AshGraphql, however, | ||
you will need to use `AshGraphql.load_fields/4` to ensure that any | ||
requested fields are loaded. | ||
|
||
For example: | ||
|
||
```elixir | ||
query do | ||
field :custom_get_post, :post do | ||
arg(:id, non_null(:id)) | ||
|
||
resolve(fn %{id: post_id}, resolution -> | ||
with {:ok, post} when not is_nil(post) <- Ash.get(AshGraphql.Test.Post, post_id) do | ||
AshGraphql.load_fields(post, AshGraphql.Test.Post, resolution) | ||
end | ||
end) | ||
end | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters