Skip to main content

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

starlette_graphene-1.0.0.tar.gz (52.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starlette_graphene-1.0.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

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

Hashes for starlette_graphene-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8dff2b69daadeba3456b09814c47e0d5865669cd8f52981e93db837d3926169b
MD5 ec081ef52a5b0f0b924239ba2754794a
BLAKE2b-256 006c58233012246c98072c50a74d2f08b88c7f7c5cea885eb53627a7657b4872

See more details on using hashes here.

Provenance

The following attestation bundles were made for starlette_graphene-1.0.0.tar.gz:

Publisher: publish.yml on bigbag/starlette-graphene

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file starlette_graphene-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for starlette_graphene-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cc5d4707f7bc140ed2580f87b95df6e5e4b0fe0298eaa356fedc970daaab254
MD5 7a23f955d7f29e37b3dff8beb524552d
BLAKE2b-256 5970e736f8f5f8cc7e5b33ecd3519f4e3d24a69d16c09d9a60ab47268440db82

See more details on using hashes here.

Provenance

The following attestation bundles were made for starlette_graphene-1.0.0-py3-none-any.whl:

Publisher: publish.yml on bigbag/starlette-graphene

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page