-
Notifications
You must be signed in to change notification settings - Fork 185
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
how to upload file #68
Comments
I would love to know whether |
It doesn't look like this library currently supports files. Is there any plan to support the graphql multipart request spec in the future? Happy to work on a PR for this as well. |
@leahein the library doesn't support file uploads but there is a repo which implements that for Django and Flask servers, would be worth checking it: graphene-file-upload. |
I was looking for file upload support for a python client that uses |
@leahein best idea would be a separated repo to support this feature as this would be a third party integration with |
I think this would be a great addition to this library. I will accept your pull request in my own PR #70 if it comes with 100% test code coverage (and documentation). Note: to create temporary files in the tests, you can use this method You can create a test which will create a temporary text file, send this file in a mutation to the local created aiohttp server, the server will return the first line from the file. Then another test with a mutation with a list of files which return a list of first lines. |
@leszekhanusz Thanks for the details! I will work on adding file support 👍 |
@leahein did you make some progress on this ? I'll have some time in the following weeks so I will maybe start to implement this myself. |
I did start on the feature here, but it's not complete. |
@leahein The link should be https://github.com/leahein/gql/tree/file-support :) At the end, the base implementation to implement should be https://github.com/jaydenseric/graphql-multipart-request-spec |
@leszekhanusz would you be able to implement this feature in a month or two ? I'm really looking forward to have this feature in this library. |
This is now available in release v3.0.0a3. Tests and feedback is welcome. |
Is file-upload support planned for sync transport? I cannot use async io in my application. |
@maaft |
The issue with AIOHTTPTransport is that it creates a new session everytime you execute a query/mutation. That sounds very inefficient and also I get random "Transport is already connected" Exceptions from time to time. Might be some race conditions maybe. |
Not necessarily, you can execute multiple queries and mutations on the same session (See async usage and async advanced usage). If you want to do it synchronously, it is still possible by running
I suspect you try to execute queries from different threads or task with the same transport. If that is not the case, and if you can reproduce a minimal example, please submit an issue. |
Yes, that is indeed the case. I'm also thinking about rewriting all my code to make use of asyncio (instead of threads & processes) but unfortunately I rely on external libraries (pytorch in this case) that make heavy use of threads and processes already. And there is no way around using pytorch sadly. It's the defacto standard in machine learning. But who knows, maybe it will work just fine with asyncio. I'll have to try. Thanks! |
See also #179 And to be clear, it should be possible to support file uploads with the RequestsHTTPTransport. I'll accept a PR if it is well tested. |
@leszekhanusz yes, it works. Thank you! |
Is there any example to show how to upload a file to the "Input!"?
The text was updated successfully, but these errors were encountered: