apollo-phoenix-websocket icon indicating copy to clipboard operation
apollo-phoenix-websocket copied to clipboard

file uploads support

Open G3z opened this issue 6 years ago • 4 comments

Are uploads supported ? absinthe plug has support for them (types) And If you think uploads over WS are not a good idea, would it be possible to use a more traditional REST approach maybe combining APW with something like apollo-upload-client

G3z avatar Aug 31 '17 23:08 G3z

this medium article could be helpful

G3z avatar Sep 01 '17 12:09 G3z

Hey,

Have you tried simply sending the file content perhaps Base64 encoded ? Anyways when you use APW you are not serializing forms, somehow you need to construct the mutation query object, so why not simply put there the file content. Haven't had the need to upload files via APW myself, but this is what I'd try at first. Otherwise you can certainly expose the the very same schema via websockets and REST if you feel like using apollo-upload-client.

vic avatar Sep 04 '17 01:09 vic

I am using apollo client for API, over websocket - but doing file uploads via axios + multi-part form posts.

Depending on the file sizes you are dealing with; reading the file on the client, and encoding as a string can be slow - and will not be transparently chunked like when uploading a file via a post request as multipart form.

Apollo upload client is interesting, but would require the upload server - not ideal in a phoenix/elixir stack...

I would stick with handing uploads via post, and create a generic gql object to represent the file - and to pass around download URIs to the client.

You can directly modify your apollo cache with the response of a form post/upload - which integrates file metadata etc into apollo cache nicely, for it to live with the rest of your apollo data.

My thoughts anyway!

harmon25 avatar Sep 27 '17 20:09 harmon25

Thank you for your suggestion I'll try that asap. I guess that's the best solution for the present but since sending blobs over websockets is possible (stackoverflow.com) I tought we could make APW feature-complete (this could require help from absinthe team)

G3z avatar Sep 27 '17 23:09 G3z