Comments (22)
@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.
from gql.
Happy to work on a PR for this as well.
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.
from gql.
I did start on the feature here, but it's not complete.
Right now there are utils
to check whether a request contains files, and I started the transformation for sending them with the requests
lib.
from gql.
@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
from gql.
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.
from gql.
@maaft Could you please check if the PR #244 works well for you?
from gql.
I would love to know whether gql
supports this, as well.
from gql.
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.
from gql.
@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.
from gql.
@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 graphene-file-upload
server-side.
I found this one that seems to support file uploads well.
from gql.
@leahein best idea would be a separated repo to support this feature as this would be a third party integration with gql
library, hence making easier to maintain the core features as there aren't many contributors around here 🤔
from gql.
Now that the aiohttp transport is implemented in #70 It should be relatively easy to incorporate the implementation from aiogqlc
from gql.
Now that #70 has been merged, if you are still interested you should create your PR directly from the repo now.
from gql.
@leszekhanusz Thanks for the details! I will work on adding file support 👍
from gql.
@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.
from gql.
This is now available in release v3.0.0a3. Tests and feedback is welcome.
from gql.
Is file-upload support planned for sync transport? I cannot use async io in my application.
from gql.
@maaft
No, it is not planned. But you can use AIOHTTPTransport in a sync manner if you want.
from gql.
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.
from gql.
The issue with AIOHTTPTransport is that it creates a new session every time you execute a query/mutation. That sounds very inefficient
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 loop.run_until_complete
yourself like in Client::execute
and also I get random "Transport is already connected" Exceptions from time to time. Might be some race conditions maybe.
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.
from gql.
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!
from gql.
@leszekhanusz yes, it works. Thank you!
from gql.
Related Issues (20)
- DSL Question HOT 5
- `KeyError` when parsing result using fragment and nested field HOT 3
- 3.5 Beta: overlapping_fields_can_be_merged: directives are None HOT 9
- DSL, Fragments and unions HOT 4
- gql should have a websockets-client transport HOT 4
- Unable to print schema with gql and error is an SSL error HOT 1
- Cannot use gql with httpx transport and trio HOT 3
- Tests fail out of the box. HOT 2
- Any best practice using async gql with FastAPI? HOT 2
- DSL how to select fields which are Python reserved keywords HOT 2
- [Feature] Support Subscriptions HTTP Multipart Protocol HOT 6
- Handling decimals with longer than 6 scale? HOT 7
- Timeout error during execution of mutation when no of async tasks is above 5000 + HOT 1
- Request/Response payloads logged at level INFO HOT 5
- requests_toolbelt isn't listed as an optional dependency although required for logging changes HOT 1
- Add retry logic to httpx Transport HOT 4
- Shopify error: Prefix "query" when sending a mutation HOT 3
- retry_execute can not handle TransportQueryError HOT 1
- Error when using gqc client under windows HOT 6
- Add change log to repository main directory? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gql.