Class: Graphql::Generators::TypeGeneratorBase::NormalizedField

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/graphql/type_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, type_expr, null) ⇒ NormalizedField

Returns a new instance of NormalizedField.


119
120
121
122
123
# File 'lib/generators/graphql/type_generator.rb', line 119

def initialize(name, type_expr, null)
  @name = name
  @type_expr = type_expr
  @null = null
end

Instance Method Details

#to_input_argumentObject


129
130
131
# File 'lib/generators/graphql/type_generator.rb', line 129

def to_input_argument
  "argument :#{@name}, #{@type_expr}, required: false"
end

#to_object_fieldObject


125
126
127
# File 'lib/generators/graphql/type_generator.rb', line 125

def to_object_field
  "field :#{@name}, #{@type_expr}#{@null ? '' : ', null: false'}"
end