module GraphQL::StaticValidation::FragmentNamesAreUnique
Public Class Methods
(GraphQL::Language::Nodes::Document document, GraphQL::StaticValidation::ValidationContext context) → void
Source
# File lib/graphql/static_validation/rules/fragment_names_are_unique.rb, line 10 def initialize(document, context) super @fragments_by_name = Hash.new { |h, k| h[k] = [] } #: Hash[String, Array[GraphQL::Language::Nodes::FragmentDefinition]] end
Calls superclass method
Public Instance Methods
(GraphQL::Language::Nodes::Document _n, GraphQL::Language::Nodes::AbstractNode? _p) → void
Source
# File lib/graphql/static_validation/rules/fragment_names_are_unique.rb, line 24 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
Calls superclass method
(GraphQL::Language::Nodes::FragmentDefinition node, GraphQL::Language::Nodes::AbstractNode? parent) → void
Source
# File lib/graphql/static_validation/rules/fragment_names_are_unique.rb, line 16 def on_fragment_definition(node, parent) # The default proc creates the Array: fragments = @fragments_by_name[node.name] #: as !nil fragments << node super end
Calls superclass method