/gql

A GraphQL client in Python

Primary LanguagePythonMIT LicenseMIT

GQL

This is a GraphQL client for Python. Plays nicely with graphene, graphql-core, graphql-js and any other GraphQL implementation compatible with the spec.

GQL architecture is inspired by React-Relay and Apollo-Client.

travis pypi Anaconda-Server Badge coveralls

Installation

$ pip install gql

Usage

The example below shows how you can execute queries against a local schema.

from gql import gql, Client

client = Client(schema=schema)
query = gql('''
{
  hello
}
''')

client.execute(query)

If you want to add additional headers when executing the query, you can specify these in a transport object:

from gql import Client
from gql.transport.requests import RequestsHTTPTransport

client = Client(transport=RequestsHTTPTransport(
     url='/graphql', headers={'Authorization': 'token'}), schema=schema)

License

MIT License