Skip to main content

🦄🍓 Django Strawberry Framework

build coveralls license changelog

GraphQL for Django the way DRF taught you: class Meta, not decorators. Built on Strawberry, with a cooperative N+1 optimizer in the box.

from django_strawberry_framework import DjangoType, finalize_django_types

class CategoryType(DjangoType):
    class Meta:
        model = Category
        fields = ("id", "name")

class ItemType(DjangoType):
    class Meta:
        model = Item
        fields = ("id", "name", "category")

finalize_django_types()

That's a complete model-backed type. Relations wire themselves. Mount DjangoOptimizerExtension on the schema and nested selections become select_related / prefetch_related / only() without you touching a resolver; without the extension the types still resolve, one lazy load at a time.

Why this package exists

Django developers think in class Meta, querysets, DRF, and django-filter. Strawberry's existing Django integration thinks in decorators. This package keeps Strawberry as the engine and makes class Meta the configuration surface, so it feels like graphene-django evolved onto a modern engine rather than replaced by a different one.

What you get

Everything hangs off one Meta. Fields, Relay, filtering, ordering, all on the type:

class ItemType(DjangoType):
    class Meta:
        model = Item
        fields = ("id", "name", "category", "entries")
        interfaces = (relay.Node,)
        filterset_class = ItemFilter   # a django-filter-shaped FilterSet
        orderset_class = ItemOrder     # its OrderSet twin

Root fields in one line. DjangoConnectionField gives Relay cursor pagination with filter: / orderBy: derived from the type above; DjangoListField is the plain-list alternative.

@strawberry.type
class Query:
    all_items: DjangoConnection[ItemType] = DjangoConnectionField(ItemType)
    all_categories: list[CategoryType] = DjangoListField(CategoryType)

Every DjangoListField publishes nullable offset and limit arguments, and conditionally publishes orderBy when the target type declares Meta.orderset_class. The contract is strictly ordered-offset paging rather than stable or repeatable pagination: offset > 0 requires a visible active order (via orderBy or a still-effective model Meta.ordering). The skip coordinate is always bounded by ResourcePolicy, and the returned-row window is too unless the field opts into trusted_max_rows=True, which lets its declared max_rows outrank the policy. Neither bound injects a primary-key tiebreaker or DISTINCT.

Three mutation flavors, one shape. Write against the model, a Django form, or a DRF serializer. Inputs are generated, and all three report validation through the same FieldError envelope.

class CreateItem(DjangoMutation):
    class Meta:
        model = Item
        operation = "create"

class CreateItemViaForm(DjangoModelFormMutation):
    class Meta:
        form_class = ItemModelForm
        operation = "create"

class CreateItemViaSerializer(SerializerMutation):
    class Meta:
        serializer_class = ItemSerializer
        operation = "create"

And the rest:

  • N+1 detection. DjangoOptimizerExtension(strictness="raise") turns an unplanned lazy load into an error, so N+1 fails CI instead of surprising production.
  • Visibility that cascades. Override get_queryset as you already do; apply_cascade_permissions pushes it across FK / OneToOne edges with zero extra queries.
  • Write permissions by default. Generated mutations deny unless DjangoModelPermission (Django's add / change / delete) or your own class says yes.
  • Production defaults. DjangoSchema masks unexpected exceptions behind a correlationId and enforces an execution resource budget (ResourcePolicy: document size, depth, aliases, list rows, uploads), DjangoGraphQLView / AsyncDjangoGraphQLView cap request bodies, and file output hides the server's filesystem path by default (Meta.filesystem_path_fields restores it per field). Build on plain Strawberry's schema or view and you keep none of these.
  • Session auth. Opt-in login / logout / register mutations and a current_user query.
  • Tooling. TestClient for in-process GraphQL tests, DjangoDebugExtension for SQL in extensions.debug, django-debug-toolbar integration, and a Channels router for subscriptions.

Why it's fast

Five optimizer wins over strawberry-graphql-django:

  • Cross-request plan cache. Every repeat of a cacheable query is a hit from a 256-entry LRU, so its selection tree is walked once, not on every request. Plans that bake in a request-scoped get_queryset are deliberately uncacheable and rebuild each time.
  • N+1 detection. Upstream is preventive only; strictness="raise" is a detective mode.
  • FK-id join elision. { relation { id } } reads the FK column already on the parent, no join.
  • Class-creation-time metadata. Frozen when the type is created, not memoized on first request.
  • Postgres lateral nested pagination. Nested connection pages via CROSS JOIN LATERAL, paging per parent instead of numbering every child. Opt-in; measured 6.4× on dense count-free pages in one local run (the benchmark runs the totalCount shape separately).

Benchmarks: bench_plan_cache.py, bench_optimizer_walk.py, bench_nested_fetch.py (needs FAKESHOP_PG_DSN) and importtime_report.py. Numbers are from one machine; run them on yours.

Is this for you?

graphene-django strawberry-graphql-django this package
Config surface class Meta decorators + annotations class Meta
N+1 handling no bundled optimizer bundled optimizer cooperative optimizer that respects your own select_related / prefetch_related
N+1 detection none preventive only strictness="raise"
Filtering django-filter FilterSet filter_type decorated classes FilterSet + Meta.filterset_class
Mutations form and serializer classes create / update / delete decorators model, form, and serializer on one Meta
Unregistered relation target silently dropped DjangoModelType { pk } stub raises at finalize_django_types(), naming the field

Coming from graphene-django: your Meta stays, DjangoObjectType becomes DjangoType. Coming from strawberry-graphql-django: keep Strawberry, lose the decorators. Coming from DRF: model / fields / exclude / filterset_class mean what you think they mean.

Status

0.0.15, alpha, single maintainer. Good for internal tools and prototypes, not production yet; public names are stable, edge cases are still hardening. The bundled examples/fakeshop/ is a development fixture and refuses to run with DEBUG off. Going to production means your own project built against the production security profile.

Get started → docs/README.md

Install, quick start, reading and writing data, transport, and deployment all live in docs/README.md.

Inspired by

Metadata

Release files for django-strawberry-framework 0.0.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-strawberry-framework 0.0.15
File Size Uploaded Provenance Actions
django_strawberry_framework-0.0.15.tar.gz 1.7 MB With provenance Details for django_strawberry_framework-0.0.15.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-strawberry-framework 0.0.15
File Interpreter ABI Platform Actions
django_strawberry_framework-0.0.15-py3-none-any.whl Python 3 none any Details for django_strawberry_framework-0.0.15-py3-none-any.whl

Total release size: 3.4 MB

Release files / django_strawberry_framework-0.0.15.tar.gz

Download URL django_strawberry_framework-0.0.15.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
de60c1789736974fc2b317ab9d1fe48256ec8ff42725a95f87f47cc8034fa373
BLAKE2b-256 checksum
How to use checksums
9305502893b60fd76a59a3c328e2906af51ec0d18e56020869887763ffe77c26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / django_strawberry_framework-0.0.15-py3-none-any.whl

Download URL django_strawberry_framework-0.0.15-py3-none-any.whl
Size 1.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
d5b27d6a3d0496e46ca3cbbf5f75de5e4b020ef95953bd8dde30a36f443ed9ae
BLAKE2b-256 checksum
How to use checksums
0f6299fb97d2a61ed785660d15bd496c503cce5c45f564fac950a790b743da1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for django-strawberry-framework 0.0.15

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_strawberry_framework-0.0.15.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.0.15 This release

2 release files Full provenance

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