Skip to content

0.331.0

Choose a tag to compare

@botberry botberry released this 04 Oct 22:54
· 19 commits to main since this release

This release fixes strawberry.field() options in Annotated being silently
ignored on Python 3.10 to 3.13, when the field's type isn't defined yet when the
Strawberry type is created. For example, with a type defined further down the
module:

from __future__ import annotations

from typing import Annotated

import strawberry


@strawberry.type
class User:
    account: Annotated[Account, strawberry.field(permission_classes=[IsAdmin])]


@strawberry.type
class Account:
    iban: str

Strawberry couldn't evaluate the annotation when User was created, so it
skipped its options and resolved Account later, when building the schema. The
field was still in the schema, but without its permissions, name, description or
default. Strawberry now raises an UnresolvedStrawberryFieldError instead. To
fix it, pass the options as the field's default
(account: Account = strawberry.field(permission_classes=[IsAdmin])), define
Account before User, or use strawberry.lazy() for the type.

Python 3.14 and newer already read these options, and aren't affected.

This release was contributed by @patrick91 in #4664