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

Multipart request specification #358

Open
cauchy2384 opened this issue Apr 1, 2022 · 7 comments
Open

Multipart request specification #358

cauchy2384 opened this issue Apr 1, 2022 · 7 comments
Labels
internally-reviewed Internally reviewed

Comments

@cauchy2384
Copy link

Hello, I am trying to build apollo federation in my project using graphql-go-tools as the best go implementation of federation.

Grapql multipart request spec is essential to perform file uploads.
It is implemented by the gqlgen.

Could you please tell me if there is an example of multipart request implementation or plans to support it?

@jensneuse
Copy link
Member

I personally would argue against using multipart GraphQL uploads. Instead, I'd upload a file to S3 and then work with the URL of the file, which is just a string.

That said, if you're interested in using graphql-go-tools with multiplart file uploads, nothing holds you off from writing an http handler that parses a multipart request and then handles an upload as well as the graphql request.

@cauchy2384
Copy link
Author

Thank you for your response.

Anyway, uploading file via graphql is a valid option with pros & cons.

You are right, there is no issue writing a handler that works with multipart data.
Unfortunately I can not see any easy way to route graphql reqeuest to the federated service with query and file in the multipart format.

@jensneuse
Copy link
Member

@cauchy2384 Take this "gateway" as a starting point. It currently doesn't handle multipart, but can easily be added: https://github.com/jensneuse/graphql-go-tools/blob/bbc67ff664c8bfa283f8cab0f7f40cec1fd65831/examples/federation/gateway/http/http.go#L18

@cauchy2384
Copy link
Author

@jensneuse thank you, that is the example I've been working with.

Unfortunately I can't find any methods for graphql.Request or engine that will add multipart file data and pass it to the federated service.

@daniil-kzn
Copy link

daniil-kzn commented Mar 17, 2023

@cauchy2384 the meaning is that you should write your own Request, engine and etc.
I have encountered with the same problem. If you have resolved it please share you solution.

@daniil-kzn
Copy link

@jensneuse maybe you have already the solution of a file uploading?

@jensneuse
Copy link
Member

My personal opinion is to upload files to S3 and manage data through GraphQL, not blobs. You're free to build anything "around" graphql-go-tools obviously. I'm currently not interested in adding file upload capabilities. I've summarized my thoughts in this blog post a while ago: https://wundergraph.com/blog/graphql_file_uploads_evaluating_the_5_most_common_approaches

@StarpTech StarpTech added the internally-reviewed Internally reviewed label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internally-reviewed Internally reviewed
Projects
None yet
Development

No branches or pull requests

4 participants