Metadata-Version: 2.4
Name: starlette-graphene
Version: 1.0.0
Summary: A focused GraphQL-over-HTTP ASGI application for Graphene
Project-URL: Changelog, https://github.com/bigbag/starlette-graphene/blob/main/CHANGELOG.md
Project-URL: Homepage, https://github.com/bigbag/starlette-graphene
Project-URL: Issues, https://github.com/bigbag/starlette-graphene/issues
Author-email: Pavel Liashkov <pavel.liashkov@protonmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: asgi,graphene,graphql,starlette
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Requires-Dist: graphene<4,>=3.4.3
Requires-Dist: starlette<2,>=1.3.1
Description-Content-Type: text/markdown

# starlette-graphene

A focused GraphQL-over-HTTP ASGI application for Graphene and Starlette.

## Requirements

- Python 3.11–3.14
- Graphene 3.x
- Starlette

## Install

```console
uv add starlette-graphene graphene starlette
```

```console
pip install starlette-graphene
```

## Quick start

```python
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:

```console
curl -X POST http://127.0.0.1:8000/graphql \
  -H 'content-type: application/json' \
  --data '{"query":"{ hello }"}'
```

```json
{"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`.

```python
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](docs/http-api.md) for the full contract.

## Migration

Version 1.0 removes the embedded GraphiQL page and changes several transport behaviors. Read [the 1.0 migration guide](docs/migration-1.0.md) before upgrading from 0.x.

## Development

```console
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.
