Module: GraphQL::Define::AssignObjectField

Defined in:
lib/graphql/define/assign_object_field.rb

Overview

Turn field configs into a Field and attach it to a ObjectType or InterfaceType

Class Method Summary collapse

Class Method Details

.call(fields_type, name, type = nil, desc = nil, field: nil, deprecation_reason: nil, property: nil, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/graphql/define/assign_object_field.rb', line 5

def self.call(fields_type, name, type = nil, desc = nil, field: nil, deprecation_reason: nil, property: nil, &block)
  if block_given?
    field = GraphQL::Field.define(&block)
  else
    field ||= GraphQL::Field.new
  end
  type && field.type = type
  desc && field.description = desc
  property && field.property = property
  deprecation_reason && field.deprecation_reason = deprecation_reason
  field.name ||= name.to_s
  fields_type.fields[name.to_s] = field
end