Module: Graphlyte

Extended by:
SchemaQuery, SingleForwardable
Defined in:
lib/graphlyte.rb,
lib/graphlyte/dsl.rb,
lib/graphlyte/data.rb,
lib/graphlyte/lexer.rb,
lib/graphlyte/editor.rb,
lib/graphlyte/errors.rb,
lib/graphlyte/parser.rb,
lib/graphlyte/schema.rb,
lib/graphlyte/syntax.rb,
lib/graphlyte/document.rb,
lib/graphlyte/selector.rb,
lib/graphlyte/serializer.rb,
lib/graphlyte/lexing/token.rb,
lib/graphlyte/schema_query.rb,
lib/graphlyte/lexing/location.rb,
lib/graphlyte/selection_builder.rb,
lib/graphlyte/editors/canonicalize.rb,
lib/graphlyte/editors/annotate_types.rb,
lib/graphlyte/editors/with_variables.rb,
lib/graphlyte/editors/infer_signature.rb,
lib/graphlyte/editors/inline_fragments.rb,
lib/graphlyte/editors/select_operation.rb,
lib/graphlyte/parsing/backtracking_parser.rb,
lib/graphlyte/refinements/string_refinement.rb,
lib/graphlyte/refinements/syntax_refinements.rb,
lib/graphlyte/editors/remove_unneeded_spreads.rb,
lib/graphlyte/editors/collect_variable_references.rb

Overview

See: github.com/graphql/graphql-spec/blob/main/spec/Appendix%20B%20–%20Grammar%20Summary.md

This module implements tokenization of [Lexical Tokens](github.com/graphql/graphql-spec/blob/main/spec/Appendix%20B%20–%20Grammar%20Summary.md#lexical-tokens) as per the GraphQL spec.

Usage:

> Graphlyte::Lexer.lex(source)

Defined Under Namespace

Modules: Editors, Lexing, Parsing, Refinements, SchemaQuery, Syntax Classes: ArgumentBuilder, DSL, Data, Document, Editor, Lexer, Parser, Production, Schema, SelectionBuilder, Selector, Serializer, WithField

Constant Summary collapse

NO_SCHEMA_DSL =
Graphlyte::DSL.new
LexError =
Class.new(StandardError)
IllegalValue =
Class.new(ArgumentError)
ParseError =
Class.new(StandardError)
TooDeep =
Class.new(StandardError) do
  def initialize(location)
    super("Max parse depth exceeded at #{location}")
  end
end
Unexpected =
Class.new(ParseError) do
  def initialize(token)
    super("Unexpected token at #{token.location}: #{token.lexeme.inspect}")
  end
end
Expected =
Class.new(ParseError) do
  def initialize(token, expected:)
    super("Unexpected token at #{token.location}: #{token.lexeme.inspect}, expected #{expected}")
  end
end
Illegal =
Class.new(ParseError) do
  def initialize(token, reason = nil)
    msg = "Illegal token at #{token.location}: #{token.lexeme}"
    msg << ", #{reason}" if reason
    super(msg)
  end
end

Class Method Summary collapse

Methods included from SchemaQuery

schema_query

Class Method Details

.dsl(schema) ⇒ Object



33
34
35
# File 'lib/graphlyte.rb', line 33

def self.dsl(schema)
  DSL.new(schema)
end

.parse(gql) ⇒ Object



26
27
28
29
30
31
# File 'lib/graphlyte.rb', line 26

def self.parse(gql)
  ts = Graphlyte::Lexer.lex(gql)
  parser = Graphlyte::Parser.new(tokens: ts)

  parser.query
end