strawberry icon indicating copy to clipboard operation
strawberry copied to clipboard

`Annotated` is not supported

Open patrick91 opened this issue 4 years ago • 1 comments
trafficstars

The following snippets

@strawberry.input
class AddBookInput:
    title: str
    author: Annotated[str, "PII"]

Raises the following error when used in a schema:

TypeError: AddBookInput fields cannot be resolved. Unexpected type 'typing.Annotated[str, 'PII']'

We should add support for Annotated

patrick91 avatar Oct 11 '21 11:10 patrick91

I ran into this today. It would be very useful to be able to provide docstring in the type annotation instead of using field = strawberry.field(description=...) because when using classes decorated with @dataclass, that marks the field as optional and forces all subsequent fields to have default values also.

emosenkis avatar Aug 05 '22 14:08 emosenkis

This has been fixed recently I think. @emosenkis can you open a new issue for that, I'm pretty sure using strawberry.field shouldn't mark a field as optional

patrick91 avatar Oct 20 '22 18:10 patrick91