You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is what I used in Node.js, would love to do something like that for Flask in Python.
If it's not supported by flask-graphql I'd be happy to work on a pull request. Also, how would you test this without a browser, using Graphiql, Postman or something like that?
hm, have you actually worked on it? I'm using https://github.com/jaydenseric/apollo-upload-client for a client that sends multipart/form-data to the server but it seems not working.
I sub-classed the GraphQLView to properly handle multipart/form-data, as per the spec. I also created a custom scalar field that can be used for file uploads, so no need to get files out of info.context or flask.request.
Activity
michaelkuty commentedon Apr 21, 2018
hxuanhung commentedon May 4, 2018
@michaelkuty can you make it work with Apollo? I got "Must provide query string." error when trying to send
multipart/form-data;to the server.michaelkuty commentedon May 4, 2018
In apollo you must use something like middleware or something else..
hxuanhung commentedon May 4, 2018
hm, have you actually worked on it? I'm using
https://github.com/jaydenseric/apollo-upload-clientfor a client that sendsmultipart/form-datato the server but it seems not working.rshk commentedon May 24, 2018
Ok, just managed to get it to work with Apollo. The problem lies with incorrect handling of the multipart-encoded request, here: https://github.com/graphql-python/flask-graphql/blob/master/flask_graphql/graphqlview.py#L126-L127
I sub-classed the GraphQLView to properly handle
multipart/form-data, as per the spec. I also created a custom scalar field that can be used for file uploads, so no need to get files out ofinfo.contextorflask.request.https://gist.github.com/rshk/97fd7b444e48c60218addb2b64897572
This will work with the version of
flask-graphqlcurrently in pypi; I haven't tested whith themasterversion yet (but should still work).I can open a PR with the changes (I have unit tests covering that
place_files_in_operationstoo).hxuanhung commentedon May 24, 2018
Similar to https://github.com/lmcgartland/graphene-file-upload/blob/master/graphene_file_upload/__init__.py
We can change a few things like I mentioned in lmcgartland/graphene-file-upload#3 to make it work for Flask.
rshk commentedon Jul 24, 2018
See #51