rubocop-graphql icon indicating copy to clipboard operation
rubocop-graphql copied to clipboard

GraphQL/ExtractInputType being thrown inside an input type object

Open ab320012 opened this issue 3 years ago • 3 comments

Hey guys not sure if this is still maintained, for some reason running rubocop -a is throwing several GraphQL/ExtractInputType errors inside of an input type object

example of the error:

app/graphql/types/public/program_application_attributes.rb:11:7: C: GraphQL/ExtractInputType: Consider moving arguments to a new input type
      argument :company_size, String, required: false, description: 'size of company ex. 11-50'

example of the file structure and class definition

# app/graphql/types/public/program_application_attributes.rb
module Types
  module Public
    class ProgramApplicationAttributes < Types::BaseInputObject
      argument :company_size, String, required: false, description: 'size of company ex. 11-50'

do you guy have any idea how to fix the error without disabling the feature?

ab320012 avatar Oct 04 '21 17:10 ab320012

Hi @ab320012, could you please show me the whole ProgramApplicationAttributes class?

DmitryTsepelev avatar Oct 04 '21 17:10 DmitryTsepelev

Hey @DmitryTsepelev its what i sent over to you except with probably 12 arguments all strings with the same required flag

ab320012 avatar Oct 04 '21 17:10 ab320012

I guess the issue is that we should run this cop only for mutations. I'll mark it as bug, but the temporary fix should be something like this added to your .rubocop.yml:

GraphQL/ExtractInputType:
  Inclide:
    - 'graphql/mutations/**/*.rb'

Please let me know if it helps!

DmitryTsepelev avatar Oct 04 '21 18:10 DmitryTsepelev