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) ⇒ Message

Returns a new instance of Message.



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

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

Instance Attribute Details

#colObject (readonly)

Returns the value of attribute col.



13
14
15
# File 'lib/graphql/static_validation/message.rb', line 13

def col
  @col
end

#lineObject (readonly)

Returns the value of attribute line.



13
14
15
# File 'lib/graphql/static_validation/message.rb', line 13

def line
  @line
end

#messageObject (readonly)

Returns the value of attribute message.



13
14
15
# File 'lib/graphql/static_validation/message.rb', line 13

def message
  @message
end

Instance Method Details

#to_hObject

A hash representation of this Message



22
23
24
25
26
27
# File 'lib/graphql/static_validation/message.rb', line 22

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