Class: RuboCop::Cop::GraphQL::ArgumentDescription

Inherits:
Base
  • Object
show all
Includes:
GraphQL::NodePattern
Defined in:
lib/rubocop/cop/graphql/argument_description.rb

Overview

This cop checks if each field has a description.

Examples:

# good

class BanUser < BaseMutation
  argument :uuid, ID, required: true, description: "UUID of the user to ban"
end

# bad

class BanUser < BaseMutation
  argument :uuid, ID, required: true
end

Constant Summary collapse

MSG =
"Missing argument description"
RESTRICT_ON_SEND =
%i[argument].freeze

Instance Method Summary collapse

Methods included from GraphQL::NodePattern

#argument?, #field?, #field_definition?, #field_definition_with_body?

Instance Method Details

#on_send(node) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/rubocop/cop/graphql/argument_description.rb', line 27

def on_send(node)
  return unless argument?(node)

  argument = RuboCop::GraphQL::Argument.new(node)

  add_offense(node) unless argument.description
end