class GraphQL::StaticValidation::FieldsWillMergeError
Attributes
Public Class Methods
Source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 9 def initialize(kind:, field_name:) super(nil) @field_name = field_name @kind = kind @conflicts = [] # Indexes of `@nodes`, so that `add_conflict` doesn't compare `node` with each one @node_ids = {}.compare_by_identity #: Hash[GraphQL::Language::Nodes::AbstractNode, bool] @nodes_by_location = nil #: Hash[Integer?, Hash[Integer?, Array[GraphQL::Language::Nodes::AbstractNode]]]? end
Calls superclass method
GraphQL::StaticValidation::Error::new
Public Instance Methods
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 34 def add_conflict(node, conflict_str) # Check if we already have an error for this exact node. # Use object identity first (fast path), then fall back to # value + location comparison for duplicate AST nodes. return if @node_ids.key?(node) nodes_at_line = (@nodes_by_location ||= {})[node.line] ||= {} nodes_at_location = nodes_at_line[node.col] if nodes_at_location # already have an error for this node return if nodes_at_location.any? { |n| n == node } nodes_at_location << node else nodes_at_line[node.col] = [node] end @node_ids[node] = true @nodes << node @conflicts << conflict_str end
Source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 68 def code "fieldConflict" end
Source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 30 def conflicts @conflicts.join(' or ') end
Source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 20 def message @message || "Field '#{field_name}' has #{kind == :argument ? 'an' : 'a'} #{kind} conflict: #{conflicts}?" end
Source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 26 def path [] end
Source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 56 def to_h extensions = { "code" => code, "fieldName" => field_name, "conflicts" => conflicts } super.merge({ "extensions" => extensions }) end
A hash representation of this Message
Calls superclass method
GraphQL::StaticValidation::Error#to_h