Skip to content

fix: strawchemy.field annotations cannot resolve plain strawberry types under postponed annotations #393

Description

@gazorby

Found while working on #391.

Under from __future__ import annotations, a strawchemy.field() annotation that references a plain strawberry type never resolves, so the schema fails to build:

from __future__ import annotations

@strawberry.type
class Plain:
    name: str

@strawberry.type
class Query:
    color_or_plain: ColorType | Plain = strawchemy.field()

UnresolvedFieldTypeError: Could not resolve the type of 'color_or_plain'. The same happens with a custom ErrorType subclass in a mutation union.

The annotation is evaluated against the strawchemy registry namespace only (StrawchemyField.type setter using self.registry_namespace in src/strawchemy/schema/field.py, and _annotation_namespace() in src/strawchemy/mapper.py), which does not contain types defined outside strawchemy.

Expected

Annotations resolve plain strawberry types from the module where the field is declared, as they do without postponed annotations.

Activity

  1. changed the title [-]fix: strawchemy.field annotations cannot resolve plain strawberry types under postponed annotations[/-] [+]fix: `strawchemy.field` annotations cannot resolve plain strawberry types under postponed annotations[/+] on Sep 28, 2026
  2. added a commit that references this issue on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions