All Projects → tryolabs → Graphql Parser

tryolabs / Graphql Parser

GraphQL parser for Python

Programming Languages

python
139335 projects - #7 most used programming language

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].