Skip to content

Commit

Permalink
Merge pull request #973 from Hermanverschooten/fix_meta_for_field
Browse files Browse the repository at this point in the history
Allow :meta on field
  • Loading branch information
benwilson512 committed Sep 29, 2020
2 parents dbf9c28 + 7e690bc commit 9ad3b28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 15 additions & 0 deletions lib/absinthe/schema/notation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,20 @@ defmodule Absinthe.Schema.Notation do
end
end

block =
case Keyword.get(attrs, :meta) do
nil ->
block

meta ->
meta_ast =
quote do
meta unquote(meta)
end

[meta_ast, block]
end

{func_ast, attrs} = Keyword.pop(attrs, :resolve)

block =
Expand All @@ -371,6 +385,7 @@ defmodule Absinthe.Schema.Notation do
attrs
|> expand_ast(caller)
|> Keyword.delete(:args)
|> Keyword.delete(:meta)
|> handle_deprecate

{attrs, block}
Expand Down
3 changes: 1 addition & 2 deletions test/absinthe/schema/manipulation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ defmodule Absinthe.Schema.ManipulationTest do
meta :some_string_meta, "non_dyn_integer meta"
end

field :non_dyn_string, :string do
meta :some_string_meta, "non_dyn_string meta"
field :non_dyn_string, :string, meta: [some_string_meta: "non_dyn_string meta"] do
resolve fn _, _ -> {:ok, "some_string_val"} end
end
end
Expand Down

0 comments on commit 9ad3b28

Please sign in to comment.