module GraphQL::StaticValidation::FragmentsAreFinite

Public Instance Methods

on_document(_n, _p) click to toggle source
Calls superclass method
# File lib/graphql/static_validation/rules/fragments_are_finite.rb, line 5
def on_document(_n, _p)
  super
  dependency_map = context.dependencies
  dependency_map.cyclical_definitions.each do |defn|
    if defn.node.is_a?(GraphQL::Language::Nodes::FragmentDefinition)
      add_error(GraphQL::StaticValidation::FragmentsAreFiniteError.new(
        "Fragment #{defn.name} contains an infinite loop",
        nodes: defn.node,
        path: defn.path,
        name: defn.name
      ))
    end
  end
end