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.

WARNING: Please note that the following documentation describes the current version which is currently only available as a pre-release The documentation for the 2.x version compatible with python<3.6 is available in the 2.x branch

GitHub-Actions pyversion pypi Anaconda-Server Badge codecov

Documentation

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

Features

Installation

WARNING: Please note that the following documentation describes the current version which is currently only available as a pre-release and needs to be installed with

$ pip install --pre gql[all]

NOTE: See also the documentation to install GQL with less extra dependencies

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.0.0rc1.tar.gz (142.1 kB view details)

Uploaded Source

File details

Details for the file gql-3.0.0rc1.tar.gz.

File metadata

  • Download URL: gql-3.0.0rc1.tar.gz
  • Upload date:
  • Size: 142.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for gql-3.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 228baaed503bc139cf368ee500f6c461b795da72592858bbb48fd3316b5e8b5b
MD5 6e40a3967893e79ff776fcfb89e08e13
BLAKE2b-256 81c2309663c0d20ff7935ddf9768001c0d44f5c6105f4d87d6ff224ddf893020

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