Strawberry GraphQL is a modern Python library for creating GraphQL APIs that leverages type annotations and dataclasses. It follows a code-first philosophy, providing type safety, async/await support, and first-class integrations with popular web frameworks like FastAPI and Django. It aims to stay close to the GraphQL specification while offering a developer-friendly experience. Currently at version 0.314.3, it has an active development cycle with frequent releases. [1, 3, 4, 7, 12, 14, 15, 20]
pip install strawberry-graphqlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a simple GraphQL schema with a `User` type and a `Query` field that returns a hardcoded user. It then instantiates a `strawberry.Schema` and explains how to run it using Strawberry's built-in development server and CLI. [3, 4]
For multipart uploads, explicitly set `multipart_uploads_enabled=True` in your view configuration. For Django CSRF, add `@csrf_exempt` to your `GraphQLView.as_view()` in `urls.py` if you need to disable it. [2]
Update any client-side code or tools that expect the `GlobalID` type in the schema to now expect `ID`. If legacy behavior is required, set `config=StrawberryConfig(relay_use_legacy_global_id=True)` when initializing the schema. [6]
Replace `graphiql=True` with `graphql_ide='graphiql'` (or `'apollo-sandbox'`, `'vega'`) in your view configuration. Example: `GraphQLView.as_view(schema=schema, graphql_ide='graphiql')`. [11]
Migrate to using Python's native `|` operator for unions (e.g., `str | int`) or `typing.Union` (e.g., `typing.Union[str, int]`). A codemod is available: `strawberry upgrade annotated-union <path>`. [5]
Review your `mypy.ini` configuration. If you're not using experimental Pydantic types, you might be able to remove `strawberry.ext.mypy_plugin`. If you are, ensure you're on a compatible version and understand its current limitations. Pydantic users primarily need `pydantic.mypy_plugin`. [5]