Class: GraphQL::StaticValidation::Message

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

Overview

Generates GraphQL-compliant validation message. Only supports one “location”, too bad :(

Defined Under Namespace

Modules: MessageHelper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, line: nil, col: nil, path: []) ⇒ Message

Returns a new instance of Message.



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

def initialize(message, line: nil, col: nil, path: [])
  @message = message
  @line = line
  @col = col
  @path = path
end

Instance Attribute Details

#colObject (readonly)

Returns the value of attribute col.



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

def col
  @col
end

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

#pathObject (readonly)

Returns the value of attribute path.



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

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,
    "path" => path,
  }
end