Skip to main content

Python GraphQL Client

Project description

Code style: black Python CI Checks Upload Python Package

Python GraphQL Client

Simple package for making requests to a graphql server.


pip install python-graphql-client


  • Query/Mutation
from python_graphql_client import GraphqlClient

# Instantiate the client with an endpoint.
client = GraphqlClient(endpoint="")

# Create the query string and variables required for the request.
query = """
    query countryQuery($countryCode: String) {
        country(code:$countryCode) {
variables = {"countryCode": "CA"}

# Synchronous request
data = client.execute(query=query, variables=variables)
print(data)  # => {'data': {'country': {'code': 'CA', 'name': 'Canada'}}}

# Asynchronous request
import asyncio

data =, variables=variables))
print(data)  # => {'data': {'country': {'code': 'CA', 'name': 'Canada'}}}
  • Subscription
from python_graphql_client import GraphqlClient

# Instantiate the client with a websocket endpoint.
client = GraphqlClient(endpoint="wss://")

# Create the query string and variables required for the request.
query = """
    subscription onMessageAdded {

# Asynchronous request
import asyncio, handle=print))
# => {'data': {'messageAdded': 'Error omnis quis.'}}
# => {'data': {'messageAdded': 'Enim asperiores omnis.'}}
# => {'data': {'messageAdded': 'Unde ullam consequatur quam eius vel.'}}
# ...

Advanced Usage

Disable SSL verification

Set the keyword argument verify=False ether when instantiating the GraphqlClient class.

from python_graphql_client import GraphqlClient

client = GraphqlClient(endpoint="wss://", verify=False)

Alternatively, you can set it when calling the execute method.

from python_graphql_client import GraphqlClient

client = GraphqlClient(endpoint="wss://"
client.execute(query="<Your Query>", verify=False)

Custom Authentication

from requests.auth import HTTPBasicAuth
from python_graphql_client import GraphqlClient

auth = HTTPBasicAuth('', 'not_a_real_password')
client = GraphqlClient(endpoint="wss://", auth=auth)


To start we'll try and use a Github project board for listing current work and updating priorities of upcoming features.


Read the Contributing documentation for details on the process for submitting pull requests to the project. Also take a peek at our Code of Conduct.

Authors and Acknowledgement

Kudos to @xkludge, @DaleSeo, and @mattbullock for getting this project started.


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.

Files for python-graphql-client, version 0.4.3
Filename, size File type Python version Upload date Hashes
Filename, size python_graphql_client-0.4.3-py3-none-any.whl (4.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size python_graphql_client-0.4.3.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page