Class: Kanji::Graph::RegisterObject

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/kanji/graph/register_object.rb

Instance Method Summary collapse

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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