Closed hyusetiawan closed 10 months ago
Hi @hyusetiawan ,
This is a known issue and unfortunately we don't have a way to solve this elegantly yet.
As I mentioned in this comment, I'm planning to add PEP 712 support to strawberry so that we may be able to workaround this in the future. In the meantime you can workaround this by doing return cast(CharObject, await ChatModel.objects.acreate(author=user, title=title))
I'm gonna close this as it is duplicated of #256 . Feel free to add more thoughts into that issue :)
returning a django model instance in a query, results in a typing error, example for a model called Chat, for an graphql called ChatObject
Expression of type "Chat" cannot be assigned to return type "ChatObject" "Chat" is incompatible with "ChatObject"
the type checker is pylanceDescribe the Bug
given the following mutation:
and the ChatObject is:
@strawberry_django.type(models.Chat, name="Chat") class ChatObject(Node): title: auto model: auto
strawberry-graphql==0.205.0 strawberry-graphql-django==0.16.0