We have updated the relationships of queries: Mapped["Query"] and material: Mapped["Material"].
We have the strawberry types here:
@strawberry.type
class Query:
id: uuid.UUID
parts: list[QueryPart]
@strawberry.type
class Material:
id: uuid.UUID
queries: list[Query]
Describe the Bug
When I have double quotes, queries: Mapped["Query"], we get this error:
2023-02-13 19:42:13,065 ERROR: [strawberry.execution] Expected Iterable, but did not find one for field 'Material.queries'.
api |
api | GraphQL request:4:5
api | 4 | queries {
api | | ^
api | 5 | parts {
When I remove the double quotes, queries: Mapped[Query], and move the class Query to the top of the file it works as expected.
We have released updated to SQLalchemy 2 and we are rewriting our schema to use the Mapped feature instead of Column. We are doing this so we can get better typing checks. https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#orm-declarative-models
For example, we have two tables:
We have updated the relationships of
queries: Mapped["Query"]
andmaterial: Mapped["Material"]
.We have the strawberry types here:
Describe the Bug
When I have double quotes,
queries: Mapped["Query"]
, we get this error:When I remove the double quotes,
queries: Mapped[Query]
, and move the class Query to the top of the file it works as expected.How do I use the PEP 484 Forward References with Strawberry? https://peps.python.org/pep-0484/#forward-references Or is there something else I am missing?
System Information
0.156.4
Additional Context
Have made a post of Discord as well: https://discord.com/channels/689806334337482765/1074780506413088939/1074780506413088939
Upvote & Fund