class GraphQL::StaticValidation::Message

Generates GraphQL-compliant validation message.

Attributes

message[R]
path[R]

Public Class Methods

new(message, path: [], nodes: []) click to toggle source
# File lib/graphql/static_validation/message.rb, line 17
def initialize(message, path: [], nodes: [])
  @message = message
  @nodes = nodes
  @path = path
end

Public Instance Methods

to_h() click to toggle source

A hash representation of this Message

# File lib/graphql/static_validation/message.rb, line 24
def to_h
  {
    "message" => message,
    "locations" => locations,
    "fields" => path,
  }
end

Private Instance Methods

locations() click to toggle source
# File lib/graphql/static_validation/message.rb, line 34
def locations
  @nodes.map{|node| {"line" => node.line, "column" => node.col}}
end