class GraphQL::StaticValidation::FieldsWillMergeError

Attributes

field_name[R]
kind[R]

Public Class Methods

new(kind:, field_name:) click to toggle source
Calls superclass method GraphQL::StaticValidation::Error::new
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 8
def initialize(kind:, field_name:)
  super(nil)

  @field_name = field_name
  @kind = kind
  @conflicts = []
end

Public Instance Methods

add_conflict(node, conflict_str) click to toggle source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 28
def add_conflict(node, conflict_str)
  return if nodes.include?(node)

  @nodes << node
  @conflicts << conflict_str
end
code() click to toggle source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 48
def code
  "fieldConflict"
end
conflicts() click to toggle source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 24
def conflicts
  @conflicts.join(' or ')
end
message() click to toggle source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 16
def message
  "Field '#{field_name}' has #{kind == :argument ? 'an' : 'a'} #{kind} conflict: #{conflicts}?"
end
path() click to toggle source
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 20
def path
  []
end
to_h() click to toggle source

A hash representation of this Message

Calls superclass method GraphQL::StaticValidation::Error#to_h
# File lib/graphql/static_validation/rules/fields_will_merge_error.rb, line 36
def to_h
  extensions = {
    "code" => code,
    "fieldName" => field_name,
    "conflicts" => conflicts
  }

  super.merge({
    "extensions" => extensions
  })
end