Sha256: 95e2905cbf32efdfc098bc4987a89bd4b07c5c5bed3ed159ce6432cf4538e50c
Contents?: true
Size: 703 Bytes
Versions: 2
Compression:
Stored size: 703 Bytes
Contents
# Generates GraphQL-compliant validation message. # Only supports one "location", too bad :( class GraphQL::StaticValidation::Message # Convenience for validators module MessageHelper # Error `message` is located at `node` def message(message, node) GraphQL::StaticValidation::Message.new(message, line: node.line, col: node.col) end end attr_reader :message, :line, :co def initialize(message, line: nil, col: nil) @message = message @line = line @col = col end def to_h { "message" => message, "locations" => locations } end private def locations @line.nil? && @col.nil ? [] : [{"line" => @line, "column" => @col}] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.3.0 | lib/graph_ql/static_validation/message.rb |
graphql-0.2.0 | lib/graph_ql/static_validation/message.rb |