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.
Describe the Bug
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:
And I get this error:
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
System Information
Additional Context
Upvote & Fund