Packages

Generators for absinthe to help reduce writing boilerplate

Current section

Files

Jump to
absinthe_generator priv templates absinthe_schema_mutation.ex.eex
Raw

priv/templates/absinthe_schema_mutation.ex.eex

defmodule <%= Macro.camelize(app_name) %>.Schema.Mutations.<%= Macro.camelize(mutation_name) %> do
<%= if moduledoc do %>
@moduledoc "<%= moduledoc %>"
<% else %>
@moduledoc false
<% end %>
use Absinthe.Schema.Notation
alias <%= Macro.camelize(app_name) %>.Resolvers
object :<%= Macro.underscore(mutation_name) %>_mutations do
<%= for mutation <- mutations do %>
<%= if mutation.description do %>@desc "<%= mutation.description %>"<% end %>
field :<%= Macro.underscore(mutation.name) %>, <%= mutation.return_type %> do
<%= for argument <- mutation.arguments do %>
arg :<%= Macro.underscore(argument.name) %>, <%= AbsintheGenerator.Type.maybe_string_atomize_type(argument.type) %><% end %>
<%= for middleware <- mutation.pre_middleware do %>
middleware <%= Macro.camelize(middleware) %><% end %>
resolve <%= mutation.resolver_module_function %>
<%= for middleware <- mutation.post_middleware do %>
middleware <%= Macro.camelize(middleware) %><% end %>
end
<% end %>
end
end