Closed noamsto closed 7 months ago
Hi @noamsto ,
I think this makes sense! Do you want to try to open a PR for it? You probably want to override the encode_json method in the django view.
Sure, I'll try to solve it and make a PR for that
I have created a PR in Strawberry project: https://github.com/strawberry-graphql/strawberry/pull/3273 If it won't be accepted for some reason, I suggest extend the BaseView in this project maybe? but I don't see a reason they won't accept it.
Using JSON type lead to:
TypeError: Object of type datetime is not JSON serializable
Describe the Bug
I have a resolver which need to return dictionaries which are not per-defined (read from a DB) Therefore I use
list[JSON]
type. i.e.:For input like this:
I get the above TypeError:
TypeError: Object of type datetime is not JSON serializable
my resolver for reference:
System Information
Additional Context
Changing the json_encoder class to DjangoJSONEncoder can solve the issue.
It looks like it was done for the other integrations strawberry-graphql/strawberry#2272
Upvote & Fund