Class: GraphQL::StaticValidation::DirectivesAreInValidLocationsError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, target:, path: nil, nodes: [], name: nil) ⇒ DirectivesAreInValidLocationsError

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



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

def initialize(message, target:, path: nil, nodes: [], name: nil)
  super(message, path: path, nodes: nodes)
  @target_name = target #: String
  @name = name #: String?
end

Instance Attribute Details

#name ⇒ Object (readonly)

: String?



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

def name
  @name
end

#target_name ⇒ Object (readonly)

: String



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

def target_name
  @target_name
end

Instance Method Details

#code ⇒ Object

: -> String



33
34
35
# File 'lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb', line 33

def code
  "directiveCannotBeApplied"
end

#to_h ⇒ Object

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



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

def to_h
  extensions = {
    "code" => code,
    "targetName" => target_name
  }.tap { |h| h["name"] = name unless name.nil? }

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