Class: GraphQL::StaticValidation::FieldsHaveAppropriateSelections

Inherits:
Object
  • Object
show all
Includes:
Message::MessageHelper
Defined in:
lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb

Overview

Scalars _can't_ have selections Objects must have selections

Instance Method Summary collapse

Methods included from Message::MessageHelper

#message

Instance Method Details

#validate(context) ⇒ Object


6
7
8
9
10
11
12
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb', line 6

def validate(context)
  context.visitor[GraphQL::Language::Nodes::Field] << -> (node, parent)  {
    return if context.skip_field?(node.name)
    field_defn = context.field_definition
    validate_field_selections(node, field_defn, context.errors)
  }
end