Rubocop extension for enforcing graphql-ruby best practices.
Install the gem:
gem install rubocop-graphqlIf you use bundler put this in your Gemfile:
gem 'rubocop-graphql', require: falseYou need to tell RuboCop to load the GraphQL extension. There are three ways to do this:
Put this into your .rubocop.yml.
require: rubocop-graphqlAlternatively, use the following array notation when specifying multiple extensions.
require:
- rubocop-other-extension
- rubocop-graphqlNow you can run rubocop and it will automatically load the RuboCop GraphQL cops together with the standard cops.
rubocop --require rubocop-graphqlRuboCop::RakeTask.new do |task|
task.requires << 'rubocop-graphql'
endAll cops are located under lib/rubocop/cop/graphql, and contain examples and documentation.
In your .rubocop.yml, you may treat the GraphQL cops just like any other cop. For example:
GraphQL/ResolverMethodLength:
Max: 3Bug reports and pull requests are welcome on GitHub at https://github.com/DmitryTsepelev/rubocop-graphql.
The gem is available as open source under the terms of the MIT License.