jaydenseric / graphql-multipart-request-spec

A spec for GraphQL multipart form requests (file uploads).
1.01k stars 56 forks source link

File upload progress #31

Closed FluorescentHallucinogen closed 4 years ago

FluorescentHallucinogen commented 4 years ago

Is it possible to get the percentage of a file uploaded? If yes, how?

mike-marcacci commented 4 years ago

As this is just a multipart HTTP request, you can keep track of the uploaded bytes exactly the same as you would for any other HTTP request, depending on whatever language/framework/libraries you're using.

dmitry commented 4 years ago

With apollo-upload-client currently it's not possible, as for the HTTP client it is using fetch which lack of this function. But you can mock it with XHR on the client side, and solve this issue, but it's still only a hack, not a production ready solution:

https://github.com/jaydenseric/apollo-upload-client/issues/88 https://github.com/jaydenseric/apollo-upload-client/issues/112

jaydenseric commented 4 years ago

@mike-marcacci is right, this spec is basic HTTP, so features like tracking upload progress is up to implementations.

General advice about how to do this for HTTP multipart requests is beyond the scope of this repo. It's probably tricky to pull off, depending if you want to track the progress of the whole request or files within the request individually. If I was building a fancy file uploader widget that allows individual file uploads to be tracked and canceled I would probably make a separate mutation request for each file.