Since strawberry-graphql==0.169.0
mypy gives the following error on graphql_app = GraphQLRouter(schema)
:
app.py:16: error: Need type annotation for "graphql_app" [var-annotated]
Found 1 error in 1 file (checked 1 source file)
pip install in your virtualenv:
pip install mypy fastapi strawberry-graphql==0.169.0
Take the example web application:
import strawberry
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
@strawberry.type
class Query:
@strawberry.field
def hello(self) -> str:
return "Hello World"
schema = strawberry.Schema(Query)
graphql_app = GraphQLRouter(schema)
app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")
Then run mypy:
$ mypy app.py
app.py:16: error: Need type annotation for "graphql_app" [var-annotated]
Found 1 error in 1 file (checked 1 source file)
The problem does not happen in version 0.168.2:
$ pip install strawberry-graphql==0.168.2
$ mypy app.py
Success: no issues found in 1 source file
A workaround is to just annotate the graphql_app variable manually:
graphql_app: GraphQLRouter = GraphQLRouter(schema)
Of course it would be nicer if it can get fixed.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too