Class: GraphQL::StaticValidation::VariableUsagesAreAllowedError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, type:, name:, argument:, error:, path: nil, nodes: []) ⇒ VariableUsagesAreAllowedError

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



17
18
19
20
21
22
23
# File 'lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb', line 17

def initialize(message, type:, name:, argument:, error:, path: nil, nodes: [])
  super(message, path: path, nodes: nodes)
  @type_name = type #: String
  @variable_name = name #: String
  @argument_name = argument #: String
  @error_message = error #: String
end

Instance Attribute Details

#argument_name ⇒ Object (readonly)

: String



12
13
14
# File 'lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb', line 12

def argument_name
  @argument_name
end

#error_message ⇒ Object (readonly)

: String



14
15
16
# File 'lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb', line 14

def error_message
  @error_message
end

#type_name ⇒ Object (readonly)

: String



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

def type_name
  @type_name
end

#variable_name ⇒ Object (readonly)

: String



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

def variable_name
  @variable_name
end

Instance Method Details

#code ⇒ Object

: -> String



42
43
44
# File 'lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb', line 42

def code
  "variableMismatch"
end

#to_h ⇒ Object

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



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb', line 27

def to_h
  extensions = {
    "code" => code,
    "variableName" => variable_name,
    "typeName" => type_name,
    "argumentName" => argument_name,
    "errorMessage" => error_message
  }

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