GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - prodigyeducation/python-graphql-client: Simple module for making requests to a graphQL server in python.

BranchesTags
Open more actions menu

Latest commit

 

History

104 Commits
104 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
python_graphql_client
python_graphql_client
 
 
tests
tests
 
 
.gitchangelog.rc
.gitchangelog.rc
 
 
.gitignore
.gitignore
 
 
.makefile.identity.inc
.makefile.identity.inc
 
 
.makefile.inc
.makefile.inc
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
setup.cfg
setup.cfg
 
 
setup.py
setup.py
 
 

Repository files navigation

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

Queries & Mutations

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'}}}

Subscriptions

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('[email protected]', 'not_a_real_password')
client = GraphqlClient(endpoint="wss://www.your-api.com/graphql", auth=auth)

Custom Headers

from python_graphql_client import GraphqlClient

headers = { "Authorization": "Token SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV" }
client = GraphqlClient(endpoint="wss://www.your-api.com/graphql", headers=headers)

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

About

Simple module for making requests to a graphQL server in python.

pypi.org/project/python-graphql-client/

Topics

graphqlgraphql-clientpythonpython-graphql-client

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

81 stars

Watchers

4 watching

Forks

19 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.