Created
December 15, 2016 09:34
-
-
Save vic/a080de9c705df6c9830713fac65e3209 to your computer and use it in GitHub Desktop.
Macro schema objects for absinthe. see https://github.com/absinthe-graphql/absinthe/issues/232
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Absinthe.Schema.Notation.Macro do | |
defmacro macro_field(name, a, b) do | |
macro(:field, [name, a, b]) | |
end | |
defmacro macro_object(name, a) do | |
macro(:object, [name, a]) | |
end | |
defmacro macro_input_object(name, a) do | |
macro(:input_object, [name, a]) | |
end | |
defp macro(type, args = [name | _]) do | |
quoted = quote do | |
Absinthe.Schema.Notation.unquote({type, [], nil})(unquote_splicing(args)) | |
end | |
quote do | |
defmacro unquote({name, [], nil}) do | |
unquote(quoted |> Macro.escape) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment