Sha256: 790ee95bfb5095573701086c81a017c49e36aa5f56796fe65665ba9fcab1fb6f
Contents?: true
Size: 973 Bytes
Versions: 61
Compression:
Stored size: 973 Bytes
Contents
# frozen_string_literal: true module GraphQL module StaticValidation # Generates GraphQL-compliant validation message. class Message # Convenience for validators module MessageHelper # Error `message` is located at `node` def message(message, nodes, context: nil, path: nil) path ||= context.path nodes = Array(nodes) GraphQL::StaticValidation::Message.new(message, nodes: nodes, path: path) end end attr_reader :message, :path def initialize(message, path: [], nodes: []) @message = message @nodes = nodes @path = path end # A hash representation of this Message def to_h { "message" => message, "locations" => locations, "fields" => path, } end private def locations @nodes.map{|node| {"line" => node.line, "column" => node.col}} end end end end
Version data entries
61 entries across 61 versions & 1 rubygems