Skip to main content

graphql-core-promise

GitHub Workflow Status (main) PyPI PyPI - Python Version License Fellow Careers

Add support for promise-based dataloaders and resolvers to graphql-core v3+. This aims to make migrating to graphene 3 and graphql-core 3 easier for existing projects.

Usage

One release supports graphql-core 3.2 and 3.3, using a separate promise adapter for each version. Python 3.11 or newer is required; CI tests Python 3.11–3.15.

graphql-core 3.2

Use PromiseExecutionContext as a replacement for the default execution context:

from graphql_core_promise import PromiseExecutionContext
from graphql.execution.execute import execute

execute(schema=..., document=..., execution_context_class=PromiseExecutionContext)

graphql-core 3.3

Use PromiseExecutor with upstream's renamed executor_class argument:

from graphql import execute
from graphql_core_promise import PromiseExecutor

execute(schema=..., document=..., executor_class=PromiseExecutor)

Both names are exported on both versions and refer to the adapter for the installed graphql-core version. The keyword passed to graphql-core must match its version: execution_context_class on 3.2 and executor_class on 3.3.

The 3.3 adapter supports synchronous query and mutation execution with promise resolvers and DataLoaders. Query fields batch together; mutation fields execute serially, including completion of each field's nested selections. The existing 3.2 adapter retains its behavior, including batching across mutation fields.

Incremental delivery (@defer and @stream), subscriptions, cancellation of pending promises, and mixing asyncio resolvers with promise resolvers are outside the supported execution contract.

With Django (graphql-core 3.2)

graphene-django's GraphqlView accepts a execution_context_class argument in the constructor. Or you can specify it as a class variable when subclassing.

For example:

view = GraphQLView.as_view(execution_context_class=PromiseExecutionContext)


# OR
class MyGraphQLView(GraphQLView):
    execution_context_class = PromiseExecutionContext

Note that this project requires graphene-django 3, which is not fully compatible with graphene-django 2.

The examples above use the graphql-core 3.2 integration API. Using this package with graphql-core 3.3 also requires the surrounding framework to support 3.3 and its executor_class API.

Versioning and compatibility

This package uses its own version numbers; they do not match graphql-core's. Adding support for an upstream version while retaining existing APIs is a minor release. Dropping a supported upstream minor line or removing a public API requires a major release. The planned release for dual 3.2/3.3 support is 3.5.0.

The dependency range is graphql-core>=3.2,<3.4,!=3.3.0. Support for 3.3 starts at 3.3.1, which fixes security and execution regressions in 3.3.0. Upstream minor versions can introduce breaking changes, so 3.4 will require a separate evaluation.

Installing this package can select graphql-core 3.3. Applications that need to remain on 3.2 should declare their own graphql-core~=3.2.0 dependency. This adapter does not make other GraphQL integrations compatible with upstream API changes.

CI runs the shared batching tests against both upstream lines and regression tests for the 3.3 adapter on Python 3.11–3.15. Ruff's UP rules enforce syntax upgrades compatible with the Python 3.11 minimum. The ty type checks run separately against each graphql-core version, targeting Python 3.11 and ignoring the adapter that cannot be imported in that environment:

# In an environment with graphql-core 3.2:
ty check --exclude graphql_core_promise/execute/executor.py

# In an environment with graphql-core 3.3:
ty check --exclude graphql_core_promise/execute/promise.py

How it works

The adapters translate graphql-core's asyncio execution methods into promise chains and resolve the completed operation synchronously.

Metadata

Release files for graphql-core-promise 3.5.0

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-core-promise 3.5.0
File Size Uploaded Provenance Actions
graphql_core_promise-3.5.0.tar.gz 24.1 kB Without provenance Details for graphql_core_promise-3.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for graphql-core-promise 3.5.0
File Interpreter ABI Platform Actions
graphql_core_promise-3.5.0-py3-none-any.whl Python 3 none any Details for graphql_core_promise-3.5.0-py3-none-any.whl

Total release size: 36.7 kB

Release files / graphql_core_promise-3.5.0.tar.gz

Download URL graphql_core_promise-3.5.0.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4c9edbb07d9012225728ec28613093e8c39519833c9191481dbe5345f3d70548
BLAKE2b-256 checksum
How to use checksums
4f5fc3d5b1e8ac512f872066124613b8907bef0c2f3e96e1a04319b9cf85708f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / graphql_core_promise-3.5.0-py3-none-any.whl

Download URL graphql_core_promise-3.5.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
059ffcedceee9368107c37c43947d9b351953e8bf6cdd7c875d7af1a089b1c79
BLAKE2b-256 checksum
How to use checksums
db0d8a447b17f83dc6a43dfd8deac0c7efa110f80e6c774f12cdc458ee20180e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for graphql-core-promise 3.5.0

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