From 7e690bcf57098fdda7dacc5db108023ba2e4b12b Mon Sep 17 00:00:00 2001 From: Herman verschooten Date: Mon, 28 Sep 2020 18:14:22 +0200 Subject: [PATCH] Allow :meta on field --- lib/absinthe/schema/notation.ex | 15 +++++++++++++++ test/absinthe/schema/manipulation_test.exs | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/absinthe/schema/notation.ex b/lib/absinthe/schema/notation.ex index cf3bae7e6f..d280308aba 100644 --- a/lib/absinthe/schema/notation.ex +++ b/lib/absinthe/schema/notation.ex @@ -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 = @@ -371,6 +385,7 @@ defmodule Absinthe.Schema.Notation do attrs |> expand_ast(caller) |> Keyword.delete(:args) + |> Keyword.delete(:meta) |> handle_deprecate {attrs, block} diff --git a/test/absinthe/schema/manipulation_test.exs b/test/absinthe/schema/manipulation_test.exs index 4e855c7c3d..96e5d3f5a3 100644 --- a/test/absinthe/schema/manipulation_test.exs +++ b/test/absinthe/schema/manipulation_test.exs @@ -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