Skip to content

DSilence/parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Dotnet Parser

AppVeyor Coverage Status NuGet MyGet Pre Release

This library contains a lexer and parser classes as well as the complete GraphQL AST model.

Lexer

Generates token based on input text.

Usage

var lexer = new Lexer();
var token = lexer.Lex(new Source("\"str\""));

Lex method always returns the first token it finds. In this case case the result would look like following. lexer example

Parser

Parses provided GraphQL expression into AST (abstract syntax tree).

Usage

var lexer = new Lexer();
var parser = new Parser(lexer);
var ast = parser.Parse(new Source(@"
{
  field
}"));

Json representation of the resulting AST would be:

{
	"Definitions": [{
		"Directives": [],
		"Kind": 2,
		"Name": null,
		"Operation": 0,
		"SelectionSet": {
			"Kind": 5,
			"Selections": [{
				"Alias": null,
				"Arguments": [],
				"Directives": [],
				"Kind": 6,
				"Name": {
					"Kind": 0,
					"Value": "field",
					"Location": {
						"End": 50,
						"Start": 31
					}
				},
				"SelectionSet": null,
				"Location": {
					"End": 50,
					"Start": 31
				}
			}],
			"Location": {
				"End": 50,
				"Start": 13
			}
		},
		"VariableDefinitions": null,
		"Location": {
			"End": 50,
			"Start": 13
		}
	}],
	"Kind": 1,
	"Location": {
		"End": 50,
		"Start": 13
	}
}

About

A lexer and parser for GraphQL in .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 94.4%
  • JavaScript 5.6%