class GraphQL::Upgrader::UnderscorizeMutationHashTransform
Find hash literals which are returned from mutation resolves, and convert their keys to underscores. This catches a lot of cases but misses hashes which are initialized anywhere except in the return expression.
Public Instance Methods
apply(input_text)
click to toggle source
# File lib/graphql/upgrader/member.rb, line 410 def apply(input_text) if input_text =~ /def resolve\(\*\*/ processor = apply_processor(input_text, ReturnedHashLiteralProcessor.new) # Use reverse_each to avoid messing up positions processor.keys_to_upgrade.reverse_each do |key_data| underscored_key = underscorize(key_data[:key].to_s) if key_data[:operator] == ":" input_text[key_data[:start]...key_data[:end]] = underscored_key else input_text[key_data[:start]...key_data[:end]] = ":#{underscored_key}" end end end input_text end