Skip to main content

GraphQL client for Python

Project description

GQL

This is a GraphQL client for Python 3.6+. 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.

GitHub-Actions pyversion pypi Anaconda-Server Badge codecov

Documentation

The complete documentation for GQL can be found at gql.readthedocs.io.

Features

Installation

You can install GQL with all the optional dependencies using pip:

pip install gql[all]

NOTE: See also the documentation to install GQL with less extra dependencies depending on the transports you would like to use

Usage

Basic usage

from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# Select your transport with a defined url endpoint
transport = AIOHTTPTransport(url="https://countries.trevorblades.com/")

# Create a GraphQL client using the defined transport
client = Client(transport=transport, fetch_schema_from_transport=True)

# Provide a GraphQL query
query = gql(
    """
    query getContinents {
      continents {
        code
        name
      }
    }
"""
)

# Execute the query on the transport
result = client.execute(query)
print(result)

WARNING: Please note that this basic example won't work if you have an asyncio event loop running. In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you. In that case you should use instead the async usage example.

Contributing

See CONTRIBUTING.md

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gql-3.2.0.tar.gz (144.5 kB view details)

Uploaded Source

Built Distribution

gql-3.2.0-py2.py3-none-any.whl (63.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file gql-3.2.0.tar.gz.

File metadata

  • Download URL: gql-3.2.0.tar.gz
  • Upload date:
  • Size: 144.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.13

File hashes

Hashes for gql-3.2.0.tar.gz
Algorithm Hash digest
SHA256 026b1c6b605cb9d6f4885ca5d8b1873a686a5b81842f356a834141bf123d4975
MD5 6c3eb801992c18451e8ce0db58925481
BLAKE2b-256 3e22b9d67e07cdb586ec591a8df4afd31fd654f84394d02dcefa4bf5e01182a9

See more details on using hashes here.

Provenance

File details

Details for the file gql-3.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: gql-3.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 63.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.13

File hashes

Hashes for gql-3.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cea850a6a922af74e01386b5c299e3ca9cf491f0c4bf039541da8e8b1f50a437
MD5 da44b3a1914829c16d3021e4dc1eb98d
BLAKE2b-256 58dc28a82f0196f9110590385c7800c4b1b60ffc78cf6d9b68878acaaab30d97

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page