class Kanji::Graph::RegisterMutation

Public Instance Methods

call() click to toggle source
# File lib/kanji/graph/register_mutation.rb, line 18
def call
  return_type = self.return_type
  attributes = self.attributes
  name = self.name
  description = self.description
  resolve_proc = self.resolve
  coercer = Graph::CoerceType

  GraphQL::Field.define do
    type -> { return_type }
    name name
    description description

    attributes.each do |attribute|
      argument(
        attribute.name,
        coercer.(attribute.type),
        attribute.description
      )
    end

    resolve resolve_proc
  end
end