Class: GraphQL::StaticValidation::ArgumentLiteralsAreCompatibleError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, type:, path: nil, nodes: [], argument_name: nil, extensions: nil, coerce_extensions: nil, argument: nil, value: nil) ⇒ ArgumentLiteralsAreCompatibleError

: (String message, type: String, ?path: Array[String | Integer]?, ?nodes: GraphQL::Language::Nodes::AbstractNode | Array, ?argument_name: String?, ?extensions: Hash[String, untyped]?, ?coerce_extensions: Hash[String, untyped]?, ?argument: GraphQL::Schema::Argument?, ?value: untyped) -> void



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

def initialize(message, type:, path: nil, nodes: [], argument_name: nil, extensions: nil, coerce_extensions: nil, argument: nil, value: nil)
  super(message, path: path, nodes: nodes)
  @type_name = type #: String
  @argument_name = argument_name #: String?
  @extensions = extensions #: Hash[String, untyped]?
  @coerce_extensions = coerce_extensions #: Hash[String, untyped]?
  @argument = argument #: GraphQL::Schema::Argument?
  @value = value #: untyped
end

Instance Attribute Details

#argument ⇒ Object (readonly)

: GraphQL::Schema::Argument?



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

def argument
  @argument
end

#argument_name ⇒ Object (readonly)

: String?



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

def argument_name
  @argument_name
end

#type_name ⇒ Object (readonly)

: String



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

def type_name
  @type_name
end

#value ⇒ Object (readonly)

: untyped



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

def value
  @value
end

Instance Method Details

#code ⇒ Object

: -> String



52
53
54
# File 'lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb', line 52

def code
  "argumentLiteralsIncompatible"
end

#to_h ⇒ Object

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



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb', line 29

def to_h
  if @coerce_extensions
    extensions = @coerce_extensions
    # This is for legacy compat -- but this key is supposed to be a GraphQL type name :confounded:
    extensions["typeName"] = "CoercionError"
  else
    extensions = {
      "code" => code,
      "typeName" => type_name
    }

    if argument_name
      extensions["argumentName"] = argument_name
    end
  end

  extensions.merge!(@extensions) unless @extensions.nil?
  super.merge({
    "extensions" => extensions
  })
end