Skip to content

Graph ML is for Graph Marked Lanuage, which is similar with Facebook's GraphQL, But mostly as a Domain-Specific expression in WeFlex team.

Notifications You must be signed in to change notification settings

weflex/graphml-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphML Parser

NPM version Build status Dependency Status Downloads

What's the Graph ML?

Graph ML is for Graph Marked Lanuage, which is similar with Facebook's GraphQL, But mostly as a Domain-Specific expression in WeFlex team.

This libaray is for generating abstract syntax tree from given Graph ML source file.

Why create this project

WeFlex team internally takes StrongLoop's loopback framework be working with most other libraries, and we are focusing on writing more graceful codebase. Loopback's JSON model definition looks good to define SQL-like tables, but we have a document-based MongoDB to be generated for views, so we found the GraphQL is close to our needs.

This project doesn't be compatible with GraphQL, if you expect a library to parse the complete GraphQL, you should visit ooflorent/graphql-parser.

Installation

$ npm install graphml-parser --save

Usage

var graphql = require('graphml-parser');
var source = fs.readFileSync('../foo.graphml').toString('utf8');
var ast = graphql.parse(source);

The GraphML file should look like the following:

Basis {
  foo,
  bar,
  items(limit=10, status=checkin) {
    bar
  }
}

Then you will get the following tree:

{
  "type": "Basis",
  "fields": [],
  "root": {
    "fields": [
      "foo",
      "bar"
    ],
    "methods": {
      "items": {
        "type": false,
        "args": {
          "limit": 10,
          "status": "checkin"
        },
        "fields": [
          "bar"
        ]
      }
    }
  }
}

License

MIT @ WeFlex, Inc.

About

Graph ML is for Graph Marked Lanuage, which is similar with Facebook's GraphQL, But mostly as a Domain-Specific expression in WeFlex team.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published