class GraphQL::Upgrader::PositionalTypeArgTransform

Move `type X` to be the second positional argument to `field …`

Public Instance Methods

apply(input_text) click to toggle source
# File lib/graphql/upgrader/member.rb, line 193
def apply(input_text)
  input_text.gsub(
    /(?<field>(?:field|input_field|return_field|connection|argument) :(?:[a-zA-Z_0-9]*)) do(?<block_contents>.*?)[ ]*type (?<return_type>.*?)\n/m
  ) do
    field = $~[:field]
    block_contents = $~[:block_contents]
    return_type = normalize_type_expression($~[:return_type], preserve_bang: true)

    "#{field}, #{return_type} do#{block_contents}"
  end
end