{"id":1881,"library":"strawberry-graphql","title":"Strawberry GraphQL","description":"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]","status":"active","version":"0.314.3","language":"en","source_language":"en","source_url":"https://github.com/strawberry-graphql/strawberry","tags":["GraphQL","API","type hints","dataclasses","ASGI","FastAPI","Django","code-first"],"install":[{"cmd":"pip install strawberry-graphql","lang":"bash","label":"Core library"},{"cmd":"pip install \"strawberry-graphql[cli]\"","lang":"bash","label":"With CLI and dev server"},{"cmd":"pip install \"strawberry-graphql[fastapi]\"","lang":"bash","label":"With FastAPI integration"},{"cmd":"pip install \"strawberry-graphql[django]\"","lang":"bash","label":"With Django integration"}],"dependencies":[{"reason":"Required Python version.","package":"python","version":">=3.10, <4.0","optional":false},{"reason":"Optional integration for FastAPI web framework.","package":"fastapi","optional":true},{"reason":"Optional integration for Django web framework.","package":"django","optional":true},{"reason":"ASGI server often used for development or production with framework integrations.","package":"uvicorn","optional":true}],"imports":[{"note":"Decorator for defining GraphQL object types, interfaces, or input types. [3, 4]","symbol":"strawberry.type","correct":"import strawberry\n@strawberry.type"},{"note":"Decorator for defining fields on GraphQL types, allowing custom resolvers or descriptions. [3, 4]","symbol":"strawberry.field","correct":"import strawberry\n@strawberry.field"},{"note":"Class to create the executable GraphQL schema. [3, 4]","symbol":"strawberry.Schema","correct":"import strawberry\nschema = strawberry.Schema(query=Query)"},{"note":"Scalar type for unique identifiers, commonly used in Relay. [8]","symbol":"strawberry.ID","correct":"import strawberry\nid: strawberry.ID"},{"note":"Used for lazy evaluation of types to resolve circular dependencies between modules. [22]","symbol":"strawberry.lazy","correct":"from typing import TYPE_CHECKING, Annotated, List\nimport strawberry\n\nif TYPE_CHECKING:\n    from .posts import Post\n\nposts: List[Annotated[\"Post\", strawberry.lazy(\".posts\")]]"},{"note":"The mypy plugin was initially removed in v0.269.0 due to new Python features (`@dataclass_transform`) and later restored with minimal support in v0.310.2 for experimental Pydantic types. Direct use might be unnecessary or require updates. [5]","wrong":"[mypy]\nplugins = strawberry.ext.mypy_plugin","symbol":"strawberry.ext.mypy_plugin","correct":"The plugin is now less critical or has changed, review mypy.ini."}],"quickstart":{"code":"import strawberry\n\n@strawberry.type\nclass User:\n    name: str\n    age: int\n\n@strawberry.type\nclass Query:\n    @strawberry.field\n    def user(self) -> User:\n        return User(name=\"Patrick\", age=100)\n\nschema = strawberry.Schema(query=Query)\n\n# To run this example locally:\n# 1. Install with `pip install \"strawberry-graphql[cli]\"`\n# 2. Save the code above as `app.py`\n# 3. Run `strawberry dev app` in your terminal.\n# 4. Access the GraphiQL interface at http://0.0.0.0:8000/graphql in your browser.","lang":"python","description":"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]"},"warnings":[{"fix":"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]","message":"In `v0.243.0`, support for GraphQL multipart file uploads was disabled by default, requiring explicit opt-in. Additionally, Django CSRF protection became enabled by default for Strawberry Django views, requiring the `csrf_exempt` decorator if previous behavior is desired. [2]","severity":"breaking","affected_versions":">=0.243.0"},{"fix":"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]","message":"In `v0.268.0`, the generated GraphQL schema type for `GlobalID` (when using `relay.Node`) was changed to `ID`. While runtime behavior is unaffected, schema introspection will now report `ID` instead of `GlobalID`. [6]","severity":"breaking","affected_versions":">=0.268.0"},{"fix":"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]","message":"In `v0.213.0`, the `graphiql` parameter used in HTTP integration views (e.g., `GraphQLView` for FastAPI, Flask, Django) was deprecated and replaced by `graphql_ide`. [11]","severity":"deprecated","affected_versions":">=0.213.0"},{"fix":"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]","message":"The `types` parameter in `strawberry.union()` was deprecated in `v0.191.0` and completely removed in `v0.312.0`. [5]","severity":"breaking","affected_versions":">=0.191.0"},{"fix":"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]","message":"The `strawberry.ext.mypy_plugin` has seen significant changes across versions. It was removed in `v0.269.0` (as it was no longer needed due to `@dataclass_transform`) but partially restored in `v0.310.2` to support experimental Pydantic types. Relying on its specific behavior or even its presence can be inconsistent. [5]","severity":"gotcha","affected_versions":">=0.269.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}