strawberry
strawberry copied to clipboard
root Query type doesn't initialize fields correctly, fields with default_factory are unininitialized
trafficstars
Describe the Bug
Here a code example
@strawberry.type
class Sub:
@strawberry.field
def foo(self) -> str:
return "bar"
@strawberry.type
class Query:
sub: Sub = strawberry.field(default_factory=Sub)
schema = strawberry.Schema(query=Query)
# this fails
result = schema.execute_sync(
"""
query TestQuery{
sub {
foo
}
}
"""
)
Solution: initialize also the root schema or provide a fallback for None in get_result
System Information
- Operating system:
- Strawberry version (if applicable):
Additional Context
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
as the source is somewhere defined outside of strawberry, None must be handled