graphsql-parser

1.1.0 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i graphsql-parser

Weekly Downloads

3

Version

1.1.0

License

MIT

Last publish

Collaborators

  • yorkie