I'm trying to use a lazy type to solve a cyclical dep issue with a generic type and I'm getting a TypeError.
I have the following code:
from typing import TYPE_CHECKING, Annotated, List
import strawberry
from mercury.models.pagination import Connection
from mercury.models.task import Task
if TYPE_CHECKING:
from mercury.models.project import Project
@strawberry.type
class Annotator:
id: str
name: str
tasks: Connection[Task]
projects: Connection[Annotated["Project", strawberry.lazy("mercury.models.project")]]
And I get this error:
TypeError: Annotator fields cannot be resolved. Could not resolve the type of 'projects'. Check that the class is accessible from the global module scope.
If I use, projects: List[Annotated["Project", strawberry.lazy("mercury.models.project")]]
the code will work without problem.
Connection is a generic type for pagination copied from here: https://strawberry.rocks/docs/guides/pagination
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