Skip to main content

Code style: black Python CI Checks Upload Python Package

Python GraphQL Client

Simple package for making requests to a graphql server.

Installation

pip install python-graphql-client

Usage

  • Query/Mutation
from python_graphql_client import GraphqlClient

# Instantiate the client with an endpoint.
client = GraphqlClient(endpoint="https://countries.trevorblades.com")

# Create the query string and variables required for the request.
query = """
    query countryQuery($countryCode: String) {
        country(code:$countryCode) {
            code
            name
        }
    }
"""
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 = asyncio.run(client.execute_async(query=query, 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://www.your-api.com/graphql")

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

# Asynchronous request
import asyncio

asyncio.run(client.subscribe(query=query, 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://www.your-api.com/graphql", verify=False)

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

from python_graphql_client import GraphqlClient

client = GraphqlClient(endpoint="wss://www.your-api.com/graphql"
client.execute(query="<Your Query>", verify=False)

Custom Authentication

from requests.auth import HTTPBasicAuth
from python_graphql_client import GraphqlClient

auth = HTTPBasicAuth('fake@example.com', 'not_a_real_password')
client = GraphqlClient(endpoint="wss://www.your-api.com/graphql", auth=auth)

Roadmap

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

Contributing

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.

License

MIT License

Metadata

Release files for python-graphql-client 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-graphql-client 0.4.3
File Size Uploaded Provenance Actions
python_graphql_client-0.4.3.tar.gz 4.1 kB Without provenance Details for python_graphql_client-0.4.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-graphql-client 0.4.3
File Interpreter ABI Platform Actions
python_graphql_client-0.4.3-py3-none-any.whl Python 3 none any Details for python_graphql_client-0.4.3-py3-none-any.whl

Total release size: 9.1 kB

Release files / python_graphql_client-0.4.3.tar.gz

Download URL python_graphql_client-0.4.3.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fdbd03115dde8776db02e60414b83b018d7d95e5752d6d5fabf21c99265f5b9d
BLAKE2b-256 checksum
How to use checksums
04bf6ebd129e957c3fd8ea1c36ae03cbd68e2342ec2bea7010d5379bd363da06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Release files / python_graphql_client-0.4.3-py3-none-any.whl

Download URL python_graphql_client-0.4.3-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5eb996702acf46110b352f61819c46065ea4f4f106158535cd471e66490b25e
BLAKE2b-256 checksum
How to use checksums
942320e60e8ce635aaef99962e3d1d0f0b3e0e9632e1bd0aeb6b6cb8436a1fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Security for python-graphql-client 0.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page