When using string type annotation to avoid circular reference, it fail to resolve with AttributeError: module 'path.to.module' has no attribute 'types'
. Where types
is a module containing strawberry.type
things
Not sure if it is a bug or a misuse but this was working with strawberry 0.140
.
Have this directory structure:
path/to/module/:
- schema.py
- types/:
- __init__.py
- first_type.py
- second_type.py
schema.py
from .types
@strawberry.type
class Query:
first: FirstType = None
types/init.py
from .first_type import FirstType
from .second_type import SecondType
types/first_type.py
from typing import Optional
import strawberry
import path.to.module.types
@strawberry.type
class FirstType:
first: "Optional[path.to.module.types.SecondType]"
types/second_type.py
from typing import Optional
import strawberry
import path.to.module.types
@strawberry.type
class SecondType:
second: "Optional[path.to.module.types.FirstType]"
Error returned at schema initialization: AttributeError: module 'path.to.module' has no attribute 'types'
Diff of updated django tests in order to reproduce:
diff.txt
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