This library contains a lexer and parser classes as well as the complete GraphQL AST model.
Generates token based on input text.
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.
Parses provided GraphQL expression into AST (abstract syntax tree).
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
}
}