Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.
What is the current behavior?
I have an InputObjectType with multiple fields and receive it in my mutation as a param. But it throws Object of type proxy is not JSON serializable on passing it as a JSONField parameter for object creation.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
a github repo, https://repl.it or similar.
I have the following Django model with a JSONField inside:
from django_jsonfield_backport import models as mysql
class RaceReport(TimeStampedModel):
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='race_reports')
parameters = mysql.JSONField(blank=True, default=dict)
Then, there's a custom `InputObjectType` which looks like this:
I am using the above input type inside the following `Mutation`:
class CreateRaceReport(graphene.Mutation):
class Arguments:
parameters = ParametersInput(required=True)
def mutate(_root, info, parameters): # noqa: N805
race_report = RaceReport.objects.create(user=info.context.user, parameters=parameters) # origin of the error
return CreateRaceReport(race_report=race_report)
* **What is the expected behavior?**
The `InputObjectType` should be resolved after we access its attributes or use`parameters.__dict__` but it stays lazy and causes the JSON encoding errors.
* **What is the motivation / use case for changing the behavior?**
Better compatibility with `JSONField`.
* **Please tell us about your environment:**
- Version: 2.1.8
- Platform: MacOS 13.0.1
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow)
- https://stackoverflow.com/questions/75412492/graphene-inputobjecttype-causing-encoding-issues-with-jsonfield
Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.
What is the current behavior? I have an
InputObjectType
with multiple fields and receive it in mymutation
as a param. But it throws Object of type proxy is not JSON serializable on passing it as aJSONField
parameter for object creation.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via a github repo, https://repl.it or similar. I have the following Django model with a JSONField inside:
class RaceReport(TimeStampedModel): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='race_reports') parameters = mysql.JSONField(blank=True, default=dict)
class ParametersInput(graphene.InputObjectType): start_point = BigInteger(required=True) end_point = BigInteger(required=True) data_type = DataType()
class CreateRaceReport(graphene.Mutation): class Arguments: parameters = ParametersInput(required=True)