Class: GraphQL::Upgrader::UnderscoreizeFieldNameTransform

Inherits:
Transform
  • Object
show all
Defined in:
lib/graphql/upgrader/member.rb

Overview

Take camelized field names and convert them to underscore case. (They’ll be automatically camelized later.)

Instance Method Summary collapse

Methods inherited from Transform

#apply_processor, #normalize_type_expression, #reindent_lines, #trim_lines, #underscorize

Instance Method Details

#apply(input_text) ⇒ Object



267
268
269
270
271
272
273
274
# File 'lib/graphql/upgrader/member.rb', line 267

def apply(input_text)
  input_text.gsub /(?<field_type>input_field|return_field|field|connection|argument) :(?<name>[a-zA-Z_0-9_]*)/ do
    field_type = $~[:field_type]
    camelized_name = $~[:name]
    underscored_name = underscorize(camelized_name)
    "#{field_type} :#{underscored_name}"
  end
end