Unless I'm doing something wrong (very possible!) it doesn't seem like the @strawberry.experimental.pydantic.type
annotation/function works with postponed Pydantic annotations...
class User(BaseModel):
id: int
first_name: str
last_name: str
email: str
date_joined: datetime.datetime
organization: "Organization"
class Organization(BaseModel):
id: int
name: str
owner: User
User.update_forward_refs()
@strawberry.experimental.pydantic.type(model=User, fields=[
'id',
'first_name',
'last_name',
'email',
'date_joined',
'organization',
])
class User:
pass
@strawberry.experimental.pydantic.type(model=Organization, fields=[
'id',
'name',
'owner',
])
class Organization:
pass
[cloud-app] File "./app/main.py", line 73, in <module>
[cloud-app] class User:
[cloud-app] File "/usr/local/lib/python3.9/site-packages/strawberry/experimental/pydantic/type.py", line 61, in wrap
[cloud-app] all_fields = [
[cloud-app] File "/usr/local/lib/python3.9/site-packages/strawberry/experimental/pydantic/type.py", line 64, in <listcomp>
[cloud-app] get_type_for_field(field),
[cloud-app] File "/usr/local/lib/python3.9/site-packages/strawberry/experimental/pydantic/type.py", line 36, in get_type_for_field
[cloud-app] type_ = replace_pydantic_types(type_)
[cloud-app] File "/usr/local/lib/python3.9/site-packages/strawberry/experimental/pydantic/type.py", line 24, in replace_pydantic_types
[cloud-app] if issubclass(type_, BaseModel):
[cloud-app] File "/usr/local/lib/python3.9/abc.py", line 102, in __subclasscheck__
[cloud-app] return _abc_subclasscheck(cls, subclass)
[cloud-app] TypeError: issubclass() arg 1 must be a class
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