Add support for promise-based dataloaders and resolvers to graphql-core v3+
Maintained. Last release 4 weeks ago, commits in 2 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install graphql-core-promisegraphql-core-promise
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.