class Kanji::Graph::RegisterObject

Public Instance Methods

call() click to toggle source
# File lib/kanji/graph/register_object.rb, line 16
def call
  name = "#{self.name}Type"
  attributes = self.attributes
  description = self.description
  coercer = Graph::CoerceType

  GraphQL::ObjectType.define do
    name name
    description description

    attributes.each do |attribute|
      field attribute.name do
        type -> { coercer.(attribute.type) }
        description attribute.description

        if attribute.resolve
          resolve attribute.resolve
        end
      end
    end
  end
end