Class: GraphQL::StaticValidation::FieldsAreDefinedOnTypeError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, type:, field:, path: nil, nodes: []) ⇒ FieldsAreDefinedOnTypeError

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



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

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

Instance Attribute Details

#field_name ⇒ Object (readonly)

: String



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

def field_name
  @field_name
end

#type_name ⇒ Object (readonly)

: String



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

def type_name
  @type_name
end

Instance Method Details

#code ⇒ Object

: -> String



34
35
36
# File 'lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb', line 34

def code
  "undefinedField"
end

#to_h ⇒ Object

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



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

def to_h
  extensions = {
    "code" => code,
    "typeName" => type_name,
    "fieldName" => field_name
  }

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