Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

wavemm/gql

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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)

To execute against a graphQL API. (We get the schema by using introspection).

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

_transport = RequestsHTTPTransport(
    url='http://api.xxx/graphql',
    use_json=True,
)

client = Client(
    retries=3,
    transport=_transport,
    fetch_schema_from_transport=True,
)
query = gql('''
{
  hello
}
''')

client.execute(query)

If you have a local schema stored as a schema.graphql file, you can do:

from graphql import build_ast_schema, parse
from gql import gql, Client

with open('schema.graphql') as source:
    document = parse(source.read())
    
schema = build_ast_schema(document)

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

client.execute(query)

License

MIT License

About

A GraphQL client in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 99.4%
  • Shell 0.6%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.