Class: GraphQL::StaticValidation::UniqueDirectivesPerLocationError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, directive:, path: nil, nodes: []) ⇒ UniqueDirectivesPerLocationError

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



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

def initialize(message, directive:, path: nil, nodes: [])
  super(message, path: path, nodes: nodes)
  @directive_name = directive #: String
end

Instance Attribute Details

#directive_name ⇒ Object (readonly)

: String



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

def directive_name
  @directive_name
end

Instance Method Details

#code ⇒ Object

: -> String



30
31
32
# File 'lib/graphql/static_validation/rules/unique_directives_per_location_error.rb', line 30

def code
  "directiveNotUniqueForLocation"
end

#to_h ⇒ Object

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



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

def to_h
  extensions = {
    "code" => code,
    "directiveName" => directive_name
  }

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