Skip to content

Commit

Permalink
fix: pass arguments to related read action
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Aug 3, 2023
1 parent d5e8781 commit 8f9e79e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline

<!-- changelog -->

## [v0.25.14](https://github.com/ash-project/ash_graphql/compare/v0.25.13...v0.25.14) (2023-08-01)




### Bug Fixes:

* recurse through array types for union checking

* don't add filter input for non-filterable resources

* array unions: for arrays of embedded types unions when graphql_unnested_unions is used, without it they return empty values (#87)

## [v0.25.13](https://github.com/ash-project/ash_graphql/compare/v0.25.12...v0.25.13) (2023-07-13)


Expand Down
2 changes: 1 addition & 1 deletion documentation/tutorials/getting-started-with-graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ If you haven't already, read the [Ash Getting Started Guide](https://hexdocs.pm/
def deps()
[
...
{:ash_graphql, "~> 0.25.13"}
{:ash_graphql, "~> 0.25.14"}
]
end
```
Expand Down
18 changes: 15 additions & 3 deletions lib/graphql/resolver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1568,12 +1568,24 @@ defmodule AshGraphql.Graphql.Resolver do
end

relationship = Ash.Resource.Info.relationship(resource, selection.schema_node.identifier) ->
related_query =
selection.arguments
|> Map.new(fn argument ->
read_action =
case relationship.read_action do
nil ->
Ash.Resource.Info.primary_action!(relationship.destination, :read)

read_action ->
Ash.Resource.Info.action(relationship.destination, read_action)
end

args =
Map.new(selection.arguments, fn argument ->
{argument.schema_node.identifier, argument.input_value.data}
end)

related_query =
args
|> apply_load_arguments(Ash.Query.new(relationship.destination))
|> set_query_arguments(read_action, args)
|> select_fields(
relationship.destination,
resolution,
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule AshGraphql.MixProject do
An absinthe-backed graphql extension for Ash
"""

@version "0.25.13"
@version "0.25.14"

def project do
[
Expand Down

0 comments on commit 8f9e79e

Please sign in to comment.