Module: RuboCop::Cop::Gusto::Graphql::IdDescriptionConcerns

Included in:
IdFieldArgumentDescription, IdFieldDescription, IdInputArgumentDescription
Defined in:
lib/rubocop/cop/gusto/graphql/id_description_concerns.rb

Constant Summary collapse

PRIMARY_ID_FIELDS =

analytics_id is intentionally excluded

i(id uuid).freeze
FIELD_CALL_PATTERN =

Matches a GraphQL field declaration capturing name and type node.

RuboCop::AST::NodePattern.new("(send nil? :field (sym $_name) $_ ...)\n")
ARGUMENT_CALL_PATTERN =

Matches a GraphQL argument declaration capturing name and type node.

RuboCop::AST::NodePattern.new("(send nil? :argument (sym $_name) $_ ...)\n")
MUTATION_OR_INPUT_BASE_SUFFIXES =

Mutation / input-object base classes conventionally end in one of these final segments (e.g. Base::PermissionedMutation, Gusto::GraphQL::Objects::BaseInputObject, Base::Input). We match on the base class's final name segment rather than a substring of its source, so unrelated bases that merely contain the word (e.g. GraphQLMutationTool, MutationHelper) are not misclassified.

%w(Mutation InputObject Input).freeze

Instance Method Summary collapse

Instance Method Details

#argument_call?(node, &block) ⇒ Boolean



32
33
34
# File 'lib/rubocop/cop/gusto/graphql/id_description_concerns.rb', line 32

def argument_call?(node, &block)
  ARGUMENT_CALL_PATTERN.match(node, &block)
end

#field_call?(node, &block) ⇒ Boolean



28
29
30
# File 'lib/rubocop/cop/gusto/graphql/id_description_concerns.rb', line 28

def field_call?(node, &block)
  FIELD_CALL_PATTERN.match(node, &block)
end