1.1.0 • Published 8 years ago

graphsql-parser v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

GraphQL Parser

NPM version Build status Dependency Status Downloads

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.