Class: GraphQL::StaticValidation::FragmentsAreFinite

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

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/fragments_are_finite.rb', line 6

def validate(context)
  context.visitor[GraphQL::Language::Nodes::FragmentDefinition] << -> (node, parent) {
    if has_nested_spread(node, [], context)
      context.errors << message("Fragment #{node.name} contains an infinite loop", node, context: context)
    end
  }
end