Module: GraphQL::Define::AssignArgument

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

Overview

Turn argument configs into a Argument.

Class Method Summary collapse

Class Method Details

.call(target, name, type = nil, description = nil, default_value: nil, &block) ⇒ Object


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

def self.call(target, name, type = nil, description = nil, default_value: nil, &block)
  argument = if block_given?
    GraphQL::Argument.define(&block)
  else
    GraphQL::Argument.new
  end
  argument.name = name.to_s
  type && argument.type = type
  description && argument.description = description
  !default_value.nil? && argument.default_value = default_value

  target.arguments[name.to_s] = argument
end