Class: GraphQL::StaticValidation::FieldsHaveAppropriateSelectionsError

Inherits:
StaticValidation::Error
  • Object
show all
Defined in:
lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, node_name:, path: nil, nodes: [], type: nil) ⇒ FieldsHaveAppropriateSelectionsError

: (String message, node_name: String, ?path: Array[String | Integer]?, ?nodes: GraphQL::Language::Nodes::AbstractNode | Array, ?type: String?) -> void



13
14
15
16
17
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 13

def initialize(message, node_name:, path: nil, nodes: [], type: nil)
  super(message, path: path, nodes: nodes)
  @node_name = node_name #: String
  @type_name = type #: String?
end

Instance Attribute Details

#node_name ⇒ Object (readonly)

: String



10
11
12
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 10

def node_name
  @node_name
end

#type_name ⇒ Object (readonly)

: String?



8
9
10
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 8

def type_name
  @type_name
end

Instance Method Details

#code ⇒ Object

: -> String



33
34
35
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 33

def code
  "selectionMismatch"
end

#to_h ⇒ Object

A hash representation of this Message : -> Hash[String, untyped]



21
22
23
24
25
26
27
28
29
30
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 21

def to_h
  extensions = {
    "code" => code,
    "nodeName" => node_name
  }.tap { |h| h["typeName"] = type_name unless type_name.nil? }

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