Class: GraphQL::StaticValidation::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/static_validation/message.rb

Overview

Generates GraphQL-compliant validation message.

Defined Under Namespace

Modules: MessageHelper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, path: [], nodes: []) ⇒ Message

Returns a new instance of Message



18
19
20
21
22
# File 'lib/graphql/static_validation/message.rb', line 18

def initialize(message, path: [], nodes: [])
  @message = message
  @nodes = nodes
  @path = path
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message



16
17
18
# File 'lib/graphql/static_validation/message.rb', line 16

def message
  @message
end

#pathObject (readonly)

Returns the value of attribute path



16
17
18
# File 'lib/graphql/static_validation/message.rb', line 16

def path
  @path
end

Instance Method Details

#to_hObject

A hash representation of this Message



25
26
27
28
29
30
31
# File 'lib/graphql/static_validation/message.rb', line 25

def to_h
  {
    "message" => message,
    "locations" => locations,
    "fields" => path,
  }
end