GraphQL Parser
graphql parser for generating abstract syntax tree
Why create this project
This is not a real parser for GraphQL standard, this project just take the good form of GraphQL and make you and your projects are able to express your configurations in this simple way.
Installation
$ npm install graphql-parser --save
Usage
var graphql = require('graphql-parser');
var source = fs.readFileSync('../foo.graphql').toString('utf8');
var ast = graphql.parse(source);
The graphQL file deos look like the following:
Basis {
foo,
bar,
items {
bar
}
}
Then you will get from ast
:
{
"type": "Basis",
"fields": [],
"root": {
"fields": [
"foo",
"bar"
],
"methods": {
"items": {
"type": false,
"fields": [
"bar"
]
}
}
}
}
License
MIT @ WeFlex, Inc.