Class: GraphQL::StaticValidation::FieldsHaveAppropriateSelectionsError

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

Instance Attribute Summary collapse

Attributes inherited from Error

#message, #path

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of FieldsHaveAppropriateSelectionsError.


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

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

Instance Attribute Details

#node_nameObject (readonly)

Returns the value of attribute node_name


6
7
8
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 6

def node_name
  @node_name
end

#type_nameObject (readonly)

Returns the value of attribute type_name


5
6
7
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 5

def type_name
  @type_name
end

Instance Method Details

#codeObject


26
27
28
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 26

def code
  "selectionMismatch"
end

#to_hObject

A hash representation of this Message


15
16
17
18
19
20
21
22
23
24
# File 'lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb', line 15

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

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