module GraphQL
def self.parse(string, as: nil)
-
(GraphQL::Language::Nodes::Document)
-
Parameters:
-
as
(Symbol
) -- If you want to use this to parse some _piece_ of a document, pass the rule name (from {GraphQL::Parser}) -
string
(String
) -- a GraphQL query string
def self.parse(string, as: nil) parser = as ? GraphQL::PARSER.send(as) : GraphQL::PARSER tree = parser.parse(string) GraphQL::TRANSFORM.apply(tree) rescue Parslet::ParseFailed => error line, col = error.cause.source.line_and_column raise [error.message, line, col, string].join(", ") end