starlette-graphene
A focused GraphQL-over-HTTP ASGI application for Graphene and Starlette.
Requirements
- Python 3.11–3.14
- Graphene 3.x
- Starlette
Install
uv add starlette-graphene graphene starlette
pip install starlette-graphene
Quick start
import graphene
from starlette.applications import Starlette
from starlette_graphene import GraphQLApp
class Query(graphene.ObjectType):
hello = graphene.String()
@staticmethod
def resolve_hello(root, info):
return "Hello, world!"
app = Starlette()
app.mount("/graphql", GraphQLApp(graphene.Schema(query=Query)))
Send a JSON operation:
curl -X POST http://127.0.0.1:8000/graphql \
-H 'content-type: application/json' \
--data '{"query":"{ hello }"}'
{"data":{"hello":"Hello, world!"}}
Context
Use context_value for a static context, or pass a sync/async callable that accepts the Starlette request connection. The callable result becomes info.context.
async def build_context(connection):
return {"request": connection}
app.mount("/graphql", GraphQLApp(schema, context_value=build_context))
HTTP behavior
The endpoint accepts JSON and raw-GraphQL POST requests, and read-only GET requests. It returns GraphQL execution errors in the response body; malformed transport input receives an HTTP 4xx response. See the HTTP API reference for the full contract.
Migration
Version 1.0 removes the embedded GraphiQL page and changes several transport behaviors. Read the 1.0 migration guide before upgrading from 0.x.
Development
uv sync --all-groups
make lint
make test
make build
make test enforces 100% branch coverage for the supported public contract.
License
starlette-graphene is distributed under the Apache License 2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file starlette_graphene-1.0.0.tar.gz.
File metadata
- Download URL: starlette_graphene-1.0.0.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dff2b69daadeba3456b09814c47e0d5865669cd8f52981e93db837d3926169b
|
|
| MD5 |
ec081ef52a5b0f0b924239ba2754794a
|
|
| BLAKE2b-256 |
006c58233012246c98072c50a74d2f08b88c7f7c5cea885eb53627a7657b4872
|
Provenance
The following attestation bundles were made for starlette_graphene-1.0.0.tar.gz:
Publisher:
publish.yml on bigbag/starlette-graphene
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
starlette_graphene-1.0.0.tar.gz -
Subject digest:
8dff2b69daadeba3456b09814c47e0d5865669cd8f52981e93db837d3926169b - Sigstore transparency entry: 2206326481
- Sigstore integration time:
-
Permalink:
bigbag/starlette-graphene@de1abf835e8b395c994df5dfce6892885c871e7a -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/bigbag
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de1abf835e8b395c994df5dfce6892885c871e7a -
Trigger Event:
push
-
Statement type:
File details
Details for the file starlette_graphene-1.0.0-py3-none-any.whl.
File metadata
- Download URL: starlette_graphene-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cc5d4707f7bc140ed2580f87b95df6e5e4b0fe0298eaa356fedc970daaab254
|
|
| MD5 |
7a23f955d7f29e37b3dff8beb524552d
|
|
| BLAKE2b-256 |
5970e736f8f5f8cc7e5b33ecd3519f4e3d24a69d16c09d9a60ab47268440db82
|
Provenance
The following attestation bundles were made for starlette_graphene-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on bigbag/starlette-graphene
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
starlette_graphene-1.0.0-py3-none-any.whl -
Subject digest:
1cc5d4707f7bc140ed2580f87b95df6e5e4b0fe0298eaa356fedc970daaab254 - Sigstore transparency entry: 2206326547
- Sigstore integration time:
-
Permalink:
bigbag/starlette-graphene@de1abf835e8b395c994df5dfce6892885c871e7a -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/bigbag
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de1abf835e8b395c994df5dfce6892885c871e7a -
Trigger Event:
push
-
Statement type: