DmitryTsepelev / rubocop-graphql

Rubocop extension for enforcing graphql-ruby best practices
MIT License
221 stars 50 forks source link

Fix FieldDefinitions autocorrection for fields with squished heredocs #164

Closed fatkodima closed 3 months ago

fatkodima commented 3 months ago

FieldDefinitions fails to correctly autocorrect in the following case:

class UserType < BaseType
  field :first_name, String, null: true, description: <<~DESC.squish
    First name.
  DESC
  field :last_name, String, null: true

  def last_name
    object.contact_data.last_name
  end

  def first_name
    object.contact_data.first_name
  end
end

It autocorrects to:

class UserType < BaseType
  field :first_name, String, null: true, description: <<~DESC.squish

  def first_name
    object.contact_data.first_name
  end

    First name.
  DESC
  field :last_name, String, null: true

  def last_name
    object.contact_data.last_name
  end
end