Class: GraphQL::StaticValidation::ArgumentLiteralsAreCompatibleError

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

Instance Attribute Summary collapse

Attributes inherited from Error

#message, #path

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ArgumentLiteralsAreCompatibleError.



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

def initialize(message, path: nil, nodes: [], type:, argument: nil, extensions: nil, coerce_extensions: nil)
  super(message, path: path, nodes: nodes)
  @type_name = type
  @argument_name = argument
  @extensions = extensions
  @coerce_extensions = coerce_extensions
end

Instance Attribute Details

#argument_nameObject (readonly)

Returns the value of attribute argument_name.



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

def argument_name
  @argument_name
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



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

def type_name
  @type_name
end

Instance Method Details

#codeObject



39
40
41
# File 'lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb', line 39

def code
  "argumentLiteralsIncompatible"
end

#to_hObject

A hash representation of this Message



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb', line 17

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