Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object of type InMemoryUploadedFile is not JSON serializable #31

Open
yoelvysmartinez opened this issue Apr 17, 2019 · 6 comments
Open

Comments

@yoelvysmartinez
Copy link

When I use the FileUploadGraphQLView view, messages thrown by graphene can not return them, Only replies

Object of type InMemoryUploadedFile is not JSON serializable

The frontend developers will not know what field is missing or what was the error that I identify by graphene

@yoelvysmartinez
Copy link
Author

this error only occurs in mutations that have an upload file and some required field is missing due to mutation input.

Graphene throws an error like this

"error": {
"errors": [
{
"message": "Variable "$input" got invalid value {"invoice": {"details": [{"cptOid": 1234, "discount": 50, "preliminar": 60}, {"cptOid": 345, "discount": 50, "preliminar": 60}], "documentDate": "2018-03-29", "documentNumber": "KUT23", "fileOid": 116, "icdOid": 221}}.\nIn field "invoice": In field "attached": Expected "Upload!", found null.",
"locations": [
{
"line": 1,
"column": 24

But FileUploadGraphQLView no show this message

@japrogramer
Copy link

you might want to try

 attachment = Upload(required=False)

@japrogramer
Copy link

japrogramer commented Apr 24, 2019

probably related to my issue #32

@yoelvysmartinez
Copy link
Author

probably related to my issue #32

No, that's not the problem, change to required = false and it did not work. The problem is that FileUploadGraphQLView is not throwing graphene errors.

@japrogramer
Copy link

japrogramer commented Apr 25, 2019

Yes, the required is false is what I thought my help.

But than in my case what you were experiencing also turned out what was happening to my post.

@kingzbauer
Copy link

kingzbauer commented Apr 3, 2020

I traced the error to this line https://github.com/graphql-python/graphql-core-legacy/blob/master/graphql/execution/values.py#L76
In my case, I was using SerializerMutation and graphql was not being able to parse my date string as type Date while checking if client inputs are valid. In that case, graphql is trying to json serialize the input which includes the InMemoryUploadedFile so as to display the error, hence the error mentioned is raised in the process.

As state, I believe it's the same issue as #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants