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



9
10
11
12
13
14
15
16
17
18
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb', line 9

def validate(context)
  context.visitor[GraphQL::Language::Nodes::Field] << ->(node, parent)  {
    field_defn = context.field_definition
    validate_field_selections(node, field_defn.type.unwrap, context)
  }

  context.visitor[GraphQL::Language::Nodes::OperationDefinition] << ->(node, parent)  {
    validate_field_selections(node, context.type_definition, context)
  }
end