fix: properly use primary read as default read_action

This commit is contained in:
Zach Daniel 2023-05-22 16:20:46 -04:00
parent 3f842045fc
commit d8b73b56e4
2 changed files with 11 additions and 5 deletions

View file

@ -921,6 +921,7 @@ defmodule AshGraphql.Graphql.Resolver do
modify_resolution: modify
}}
) do
read_action = read_action || Ash.Resource.Info.primary_action!(resource, :read).name
input = arguments[:input] || %{}
args_result =
@ -1067,6 +1068,7 @@ defmodule AshGraphql.Graphql.Resolver do
modify_resolution: modify
}}
) do
read_action = read_action || Ash.Resource.Info.primary_action!(resource, :read).name
input = arguments[:input] || %{}
args_result =
@ -1434,7 +1436,12 @@ defmodule AshGraphql.Graphql.Resolver do
end
defp set_query_arguments(query, action, arg_values) do
action = Ash.Resource.Info.action(query.resource, action)
action =
if is_atom(action) do
Ash.Resource.Info.action(query.resource, action)
else
action
end
action.arguments
|> Enum.reject(& &1.private?)

View file

@ -169,10 +169,9 @@ defmodule AshGraphql.UpdateTest do
end
test "an update with a configured read action and no identity works with an argument the same name as an attribute" do
post =
AshGraphql.Test.Api.create!(
Ash.Changeset.new(AshGraphql.Test.Post, text: "foobar", best: true)
)
AshGraphql.Test.Api.create!(
Ash.Changeset.new(AshGraphql.Test.Post, text: "foobar", best: true)
)
resp =
"""