Skip to content

Instantly share code, notes, and snippets.

@austinthecoder
Created February 6, 2025 21:46
Show Gist options
  • Save austinthecoder/5fa3aecdfc0eb73e898c4bfd8b55333e to your computer and use it in GitHub Desktop.
Save austinthecoder/5fa3aecdfc0eb73e898c4bfd8b55333e to your computer and use it in GitHub Desktop.
defmodule MyAppWeb.Schema.NonNullNotation do
defmacro field!(identifier, type) do
quote do
field(unquote(identifier), non_null(unquote(type)))
end
end
defmacro field!(identifier, type, attrs) do
quote do
field(unquote(identifier), non_null(unquote(type)), unquote(attrs))
end
end
defmacro field!(identifier, type, attrs, list) do
quote do
field(unquote(identifier), non_null(unquote(type)), unquote(attrs), unquote(list))
end
end
defmacro list_of!(type) do
quote do
list_of(non_null(unquote(type)))
end
end
defmacro arg!(identifier, type) do
quote do
arg(unquote(identifier), non_null(unquote(type)))
end
end
defmacro arg!(identifier, type, attrs) do
quote do
arg(unquote(identifier), non_null(unquote(type)), unquote(attrs))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment