Skip to content

tryolabs/graphql-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-parser

Build Status

This is a Python parser for React's GraphQL.

Lacking a specification, the parser was built to parse code along the lines of examples and other implementations of GraphQL.

Usage

from graphql_parser import parse

QUERY = '''{
  user(1) {
    name,
    email,
    profile_pic.size(64) {
      date_added
    }
  }
}
'''

parse(QUERY)

Produces:

{
  'type': 'block',
  'children': [
    {
      'type': 'call',
      'chain': ['user'],
      'arguments': ['1'],
      'body': {
        'type': 'block',
        'children': [
          'name',
          'email',
          {
            'type': 'call',
            'chain': ['profile_pic', 'size'],
            'arguments': ['64'],
            'body': {
              'type': 'block',
              'children': ['date_added']
            },
          }
        ]
      }
    }
  ]
}

License

Copyright (c) 2015 Tryolabs SRL.

Released under the MIT license.

Releases

No releases published

Packages

No packages published

Languages