Skip to content

Latest commit

 

History

History
76 lines (73 loc) · 1.84 KB

README.md

File metadata and controls

76 lines (73 loc) · 1.84 KB

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
	}
}