Skip to content

Commit

Permalink
fix: honor argument_names configuration for read & generic actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Oct 21, 2024
1 parent 3201682 commit 4e3a4dd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/resource/resource.ex
Original file line number Diff line number Diff line change
Expand Up @@ -993,9 +993,13 @@ defmodule AshGraphql.Resource do
read_action
end

argument_names = AshGraphql.Resource.Info.argument_names(resource)

read_action.arguments
|> Enum.filter(& &1.public?)
|> Enum.map(fn argument ->
name = argument_names[read_action.name][argument.name] || argument.name

type =
argument.type
|> field_type(argument, resource, true)
Expand All @@ -1004,7 +1008,7 @@ defmodule AshGraphql.Resource do
%Absinthe.Blueprint.Schema.FieldDefinition{
identifier: argument.name,
module: schema,
name: to_string(argument.name),
name: to_string(name),
description: argument.description,
type: type,
__reference__: ref(__ENV__)
Expand Down Expand Up @@ -1656,6 +1660,8 @@ defmodule AshGraphql.Resource do
end

defp generic_action_args(action, resource, schema) do
argument_names = AshGraphql.Resource.Info.argument_names(resource)

action.arguments
|> Enum.filter(& &1.public?)
|> Enum.map(fn argument ->
Expand All @@ -1664,10 +1670,12 @@ defmodule AshGraphql.Resource do
|> field_type(argument, resource, true)
|> maybe_wrap_non_null(argument_required?(argument))

name = argument_names[action.name][argument.name] || argument.name

%Absinthe.Blueprint.Schema.FieldDefinition{
identifier: argument.name,
module: schema,
name: to_string(argument.name),
name: to_string(name),
description: argument.description,
type: type,
__reference__: ref(__ENV__)
Expand Down Expand Up @@ -1824,9 +1832,13 @@ defmodule AshGraphql.Resource do
end

defp read_args(resource, action, schema, hide_inputs) do
argument_names = AshGraphql.Resource.Info.argument_names(resource)

action.arguments
|> Enum.filter(&(&1.public? && &1.name not in hide_inputs))
|> Enum.map(fn argument ->
name = argument_names[action.name][argument.name] || argument.name

type =
argument.type
|> field_type(argument, resource, true)
Expand All @@ -1835,7 +1847,7 @@ defmodule AshGraphql.Resource do
%Absinthe.Blueprint.Schema.FieldDefinition{
identifier: argument.name,
module: schema,
name: to_string(argument.name),
name: to_string(name),
description: argument.description,
type: type,
__reference__: ref(__ENV__)
Expand Down

0 comments on commit 4e3a4dd

Please sign in to comment.