Class: GraphQL::StaticValidation::OperationNamesAreValidError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



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

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

Instance Attribute Details

#operation_name ⇒ Object (readonly)

: String?



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

def operation_name
  @operation_name
end

Instance Method Details

#code ⇒ Object

: -> String



29
30
31
# File 'lib/graphql/static_validation/rules/operation_names_are_valid_error.rb', line 29

def code
  "uniquelyNamedOperations"
end

#to_h ⇒ Object

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



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

def to_h
  extensions = {
    "code" => code
  }.tap { |h| h["operationName"] = operation_name unless operation_name.nil? }

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