Skip to content

Releases: strawberry-graphql/strawberry

🍓 0.311.1

10 Mar 19:26

Choose a tag to compare

This release fixes an InvalidStateError crash in the DataLoader when a batch
load function raises an exception and some futures in the batch have already been
cancelled (e.g. due to client disconnection).

The error handler in dispatch_batch now skips cancelled futures before calling
set_exception, matching the guard that already exists in the success path
(added in #2339).

Releases contributed by @ben-xo via #4300

🍓 0.311.0

08 Mar 18:30

Choose a tag to compare

Enums can now be registered via Annotated. The preferred way is still using
@strawberry.enum as a decorator, but when you need to expose an existing enum
under a different name or alias, Annotated works as a proper type alias in all
type checkers:

from typing import Annotated
from enum import Enum
import strawberry


class IceCreamFlavour(Enum):
    VANILLA = "vanilla"
    STRAWBERRY = "strawberry"
    CHOCOLATE = "chocolate"


MyIceCreamFlavour = Annotated[
    IceCreamFlavour, strawberry.enum(description="Ice cream flavours")
]


@strawberry.type
class Query:
    @strawberry.field
    def flavour(self) -> MyIceCreamFlavour:
        return IceCreamFlavour.VANILLA

Releases contributed by @bellini666 via #4293

🍓 0.310.2

08 Mar 14:59

Choose a tag to compare

The strawberry mypy plugin has been restored with minimal support for
strawberry.experimental.pydantic types. If you use pydantic integration,
add the plugin to your mypy configuration:

[mypy]
plugins = pydantic.mypy, strawberry.ext.mypy_plugin

Releases contributed by @bellini666 via #4292

🍓 0.310.1

08 Mar 14:00

Choose a tag to compare

Fix sync execution crash with graphql-core 3.3 where execute_sync() would return a coroutine
instead of an ExecutionResult, causing RuntimeError: There is no current event loop,
because graphql-core 3.3's is_async_iterable default treats objects with __aiter__
(like Django QuerySets) as async iterables.

Now passes is_async_iterable=lambda _x: False during sync execution to prevent this.

Note: graphql-core >= 3.3.0a12 is now the minimum required version for the 3.3.x series.

Releases contributed by @bellini666 via #4267

🍓 0.310.0

08 Mar 12:18

Choose a tag to compare

Fix two NameError issues in schema-codegen output when types are referenced before they are defined.

First, forward references in field annotations (e.g. foo: Foo appearing before Foo is defined) are now handled by emitting from __future__ import annotations at the top of the generated file. Per PEP 563, this stores all annotations as strings instead of evaluating them at class definition time, so the referenced names don't need to exist yet.

Second, union definitions like FooOrBar = Annotated[Foo | Bar, strawberry.union(...)] are runtime expressions that from __future__ import annotations cannot defer. These are now correctly ordered by declaring union member types as dependencies, so unions are always emitted after their members.

Changes:

  • Emit from __future__ import annotations in generated code to handle forward references in field annotations.
  • Add member-type dependencies for union definitions so unions are emitted after their member types.
  • Ensure the schema assignment is emitted last by giving it dependencies on all other definitions.

Releases contributed by @sanlil via #4192

🍓 0.309.0

08 Mar 11:49

Choose a tag to compare

Add query property to Info class, allowing resolvers to access the full GraphQL document string sent in the request via info.query.

Example usage:

import strawberry


@strawberry.type
class Query:
    @strawberry.field
    def hello(self, info: strawberry.Info, name: str) -> str:
        print(info.query)
        return f"Hello {name}"

When executing this query:

query Hello($name: String!) {
    hello(name: $name)
}

info.query returns the full query string:

"query Hello($name: String!) {\n    hello(name: $name)\n}"

Releases contributed by @Ckk3 via #4289

🍓 0.308.3

04 Mar 12:25

Choose a tag to compare

Fix compatibility with Python 3.14 when using the Pydantic integration with Pydantic V2. Previously, importing strawberry.experimental.pydantic on Python 3.14 would trigger:

UserWarning: Core Pydantic V1 functionality isn't compatible with Python 3.14 or greater.

This is now fixed by avoiding pydantic.v1 imports on Python 3.14+.

Releases contributed by @zshuzh via #4283

🍓 0.308.2

03 Mar 17:28

Choose a tag to compare

Fix from __future__ import annotations breaking lazy types inside generic wrappers like Optional[], tuple[], dict[], Sequence[], etc. Previously only Union[], list[]/List[], and Annotated[] were handled during AST namespace resolution, causing _eval_type to fail when lazy types were nested inside other generic subscripts.

Releases contributed by @bellini666 via #4270

🍓 0.308.1

03 Mar 17:24

Choose a tag to compare

Fix ApolloTracingExtension crashing with AttributeError when executing invalid queries (e.g., { node() }). All timing attributes are now initialized in __init__ and lifecycle hooks use try/finally to ensure proper cleanup.

Releases contributed by @Br1an67 via #4271

🍓 0.308.0

03 Mar 17:14

Choose a tag to compare

This release adds support for defining fields using the Annotated syntax. This provides an
alternative way to specify field metadata alongside the type annotation.

Example usage:

from typing import Annotated

import strawberry


@strawberry.type
class Query:
    name: Annotated[str, strawberry.field(description="The name")]
    age: Annotated[int, strawberry.field(deprecation_reason="Use birthDate instead")]


@strawberry.input
class CreateUserInput:
    name: Annotated[str, strawberry.field(description="User's name")]
    email: Annotated[str, strawberry.field(description="User's email")]

This syntax works alongside the existing assignment syntax:

@strawberry.type
class Query:
    # Both styles work
    field1: Annotated[str, strawberry.field(description="Using Annotated")]
    field2: str = strawberry.field(description="Using assignment")

All strawberry.field() options are supported including description, name,
deprecation_reason, directives, metadata, and permission_classes.

Releases contributed by @patrick91 via #4059