Class: Kanji::Graph::RegisterMutation

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

Instance Method Summary collapse

Instance Method Details

#callObject



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