Skip to main content

GraphQL Utils for Python

https://circleci.com/gh/Mergifyio/graphql-utils.svg?style=svg Mergify Status

The graphql-utils Python package is a collection of utilities function for interacting with GraphQL libraries. It is meant to be library agnostic so it should work with whatever library or protocol you want.

Usage

Multi-requests

The multi-requests module allows you to send a request multiple times with different parameter. It also supports pagination, making sure that you’ll get all the results for all the requests you sent.

Example:

import requests

from graphql_utils import multi

def requests_api(query):
    return requests.post("https://myapi.com/graphql", json=query)

userlist = (
    {"login": "jd"},
    {"login": "sileht"},
    {"login": "foo"},
    {"login": "bar"},
)

result_iterator = multi.multi_query("""
    user(login: "{login}") {{
      pets(first: 100{after}) {{
        nodes {{
          name
        }}
        pageInfo {{
          hasNextPage
          endCursor
        }}
      }}
    }}""",
    iterable=userlist,
    pageinfo_path=("pets", "pageInfo"),
    send_fn=requests_api,
)

This will send one GraphQL requests with 4 queries (one for each user from userlist). As pageinfo_path was specified, if any of the query does not return all information in one request, a new query using the endCursor will be automatically sent to get the next results.

Metadata

Release files for graphql-utils 0.4

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

Source distribution (sdist)

Source distribution for graphql-utils 0.4
File Size Uploaded
graphql-utils-0.4.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for graphql-utils 0.4
File Interpreter ABI Platform
graphql_utils-0.4-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / graphql-utils-0.4.tar.gz

Download URL graphql-utils-0.4.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
08d8378b6deb731298cce549ebfc0a7398e75f1eeca4b4de609c917e4c4ea4f8
BLAKE2b-256 checksum
How to use checksums
5eab834907c55a54c6196813c4eed580b0470f908f1b3b612fe129a7f5a80f7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / graphql_utils-0.4-py3-none-any.whl

Download URL graphql_utils-0.4-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3421c821ccce7939dff7d2f95e251b56bf02c8baacb8c469ad6518a5bcb0a51
BLAKE2b-256 checksum
How to use checksums
954e6c88f7898815a4069f07ad583ca5940dfe436596f18dfdebe0f1539b3094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

0.4 This release

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 release files

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