Closed
Description
The @strawberry.field
annotation behavior has changed at typing level between strawberry 0.156.1 and 0.156.2. It should now be a callable
Describe the Bug
Consider this simple code:
import strawberry
@strawberry.type
class Author:
name: str
@strawberry.type
class Query:
@strawberry.field
async def get_authors(self) -> list[Author]:
return [
Author(name="Michael Crichton")
]
Running mypy on this is ok for strawberry 0.156.1.
On strawberry 0.156.2 this gives an error:
error: Argument 1 to "field" has incompatible type "Callable[[Query], Coroutine[Any, Any, List[Author]]]"; expected "Union[StrawberryResolver[<nothing>], Callable[..., <nothing>], Callable[..., Awaitable[<nothing>]], staticmethod[<nothing>], classmethod[<nothing>]]" [arg-type]
This is probably due to the declaration of the callable on awaitable (https://github.com/strawberry-graphql/strawberry/pull/2528/files), since switching to field as this is ok:
import strawberry
@strawberry.type
class Author:
name: str
@strawberry.type
class Query:
@strawberry.field()
async def get_authors(self) -> list[Author]:
return [
Author(name="Michael Crichton")
]