Skip to content
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

file upload support #503

Open
JohnChung111 opened this issue Aug 10, 2020 · 2 comments
Open

file upload support #503

JohnChung111 opened this issue Aug 10, 2020 · 2 comments

Comments

@JohnChung111
Copy link

hi,i am wondering how can i upload file elegantly by using sangria. as now i am using flutter graphql on client side, it do this like https://codinglatte.com/posts/flutter/flutter-and-graphql-how-to-upload-files/ . is there any implemention in sangria on server side?

@dashared
Copy link

Hi, @quanduoling !

I have been dealing with the same issue recently. Sangria doesn't have file upload support, so I decided to show you what I came up with. I am using PlayFramework, so here is the gist with all the code that you need to implement something similar.

To give you some understanding where the idea came from: my team is developing UI with typescript+react+apollo and I stumbled upon this post in Apollo blog with reference to this specification for graphql uploads. This approach has been already implemented for UI with apollo-upload-client lib and I decided to embed this specification into my server-side scala app.

Hope you find this useful!

@david-krentzlin
Copy link

david-krentzlin commented Jul 26, 2024

In our experience, running sangria in our GraphQL gateway at NewWork SE, it's not a concern that's easily solved within the engine itself. The request patterns are very different for uploads, and you'll end up in a situation where you can't feasibly optimize for all of those. Uploads tend to be slow and they tend to hog bandwidth and threads.

What worked well is to use mutations, to hand out signed URLs, to an upload service. It could for example be an S3.
Then the client uses that endpoint to push the data via HTTP. This bucket should be a temporary storage, and you have to have some means to let your application move it to a long term storage. This could be triggered either by another mutation or in the background asynchronously via messaging, if that's what your platform uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants