Class: GraphQL::StaticValidation::Error
- Inherits:
-
Object
- Object
- GraphQL::StaticValidation::Error
- Defined in:
- lib/graphql/static_validation/error.rb
Overview
Generates GraphQL-compliant validation message.
Defined Under Namespace
Modules: ErrorHelper
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
: String?.
-
#nodes ⇒ Object
readonly
: Array.
-
#path ⇒ Object
: Array[String | Integer]?.
Instance Method Summary collapse
-
#initialize(message, path: nil, nodes: []) ⇒ Error
constructor
: (String? message, ?path: Array[String | Integer]?, ?nodes: GraphQL::Language::Nodes::AbstractNode | Array) -> void.
-
#to_h ⇒ Object
A hash representation of this Message : -> Hash[String, untyped].
Constructor Details
#initialize(message, path: nil, nodes: []) ⇒ Error
: (String? message, ?path: Array[String | Integer]?, ?nodes: GraphQL::Language::Nodes::AbstractNode | Array) -> void
28 29 30 31 32 |
# File 'lib/graphql/static_validation/error.rb', line 28 def initialize(, path: nil, nodes: []) @message = #: String? @nodes = Array(nodes) #: Array[GraphQL::Language::Nodes::AbstractNode] @path = path #: Array[String | Integer]? end |
Instance Attribute Details
#message ⇒ Object (readonly)
: String?
23 24 25 |
# File 'lib/graphql/static_validation/error.rb', line 23 def @message end |
#nodes ⇒ Object (readonly)
: Array
44 45 46 |
# File 'lib/graphql/static_validation/error.rb', line 44 def nodes @nodes end |
#path ⇒ Object
: Array[String | Integer]?
25 26 27 |
# File 'lib/graphql/static_validation/error.rb', line 25 def path @path end |
Instance Method Details
#to_h ⇒ Object
A hash representation of this Message : -> Hash[String, untyped]
36 37 38 39 40 41 |
# File 'lib/graphql/static_validation/error.rb', line 36 def to_h { "message" => , "locations" => locations }.tap { |h| h["path"] = path unless path.nil? } end |