From 8f9e79e2734808947f562a4aece851e340c4f43b Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 3 Aug 2023 19:49:59 -0400 Subject: [PATCH] fix: pass arguments to related read action --- CHANGELOG.md | 13 +++++++++++++ .../tutorials/getting-started-with-graphql.md | 2 +- lib/graphql/resolver.ex | 18 +++++++++++++++--- mix.exs | 2 +- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 421483c7..5e2770c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline +## [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) diff --git a/documentation/tutorials/getting-started-with-graphql.md b/documentation/tutorials/getting-started-with-graphql.md index 2bd83af1..5ee12df9 100644 --- a/documentation/tutorials/getting-started-with-graphql.md +++ b/documentation/tutorials/getting-started-with-graphql.md @@ -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 ``` diff --git a/lib/graphql/resolver.ex b/lib/graphql/resolver.ex index 0e683739..0a04354e 100644 --- a/lib/graphql/resolver.ex +++ b/lib/graphql/resolver.ex @@ -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, diff --git a/mix.exs b/mix.exs index 787403b0..b5d1b468 100644 --- a/mix.exs +++ b/mix.exs @@ -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 [