module GraphQL::StaticValidation::FragmentNamesAreUnique

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/graphql/static_validation/rules/fragment_names_are_unique.rb, line 6
def initialize(*)
  super
  @fragments_by_name = Hash.new { |h, k| h[k] = [] }
end

Public Instance Methods

on_document(_n, _p) click to toggle source
Calls superclass method
# File lib/graphql/static_validation/rules/fragment_names_are_unique.rb, line 16
def on_document(_n, _p)
  super
  @fragments_by_name.each do |name, fragments|
    if fragments.length > 1
      add_error(GraphQL::StaticValidation::FragmentNamesAreUniqueError.new(
        %|Fragment name "#{name}" must be unique|,
        nodes: fragments,
        name: name
      ))
    end
  end
end
on_fragment_definition(node, parent) click to toggle source
Calls superclass method
# File lib/graphql/static_validation/rules/fragment_names_are_unique.rb, line 11
def on_fragment_definition(node, parent)
  @fragments_by_name[node.name] << node
  super
end