Skip to content

Receive files sent via apollo client on a spring-boot back-end #661

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

Closed
gonzalt03 opened this issue Apr 17, 2020 · 5 comments
Closed

Receive files sent via apollo client on a spring-boot back-end #661

gonzalt03 opened this issue Apr 17, 2020 · 5 comments

Comments

@gonzalt03
Copy link

The configuration of the spring-boot with graphql will it manage basic multipart requests made by Apollo client ?
Do you have an example of a complete and functional file sending implementation on a spring-boot graphql back-end?
As it stands, a 400 BAD REQUEST is returned by the spring-boot. I do not understand why. The request is however well recognized by the ContextWebFilter in the graphql-kotlin-spring-server library.

@dariuszkuc
Copy link
Collaborator

Apollo file uploads are not part of the GraphQL specification are not supported "out-of-the-box". As per #518 you will have to configure Jackson object mapper to correctly handle those types (and potentially also configure custom data fetcher to apply the custom logic - if needed).

@ilaborie
Copy link

Hi @gonzalt03 ,

We have trying to do the same thing, you can check this gist to see how we have implement the behavior.

@ilaborie
Copy link

This week, we'll be take the time to create the PR on that issue soon.

@smyrick
Copy link
Contributor

smyrick commented Apr 20, 2020

At this time we don't have intention to add support for this feature "out-of-the-box" as it is not directly related to running a generic GraphQL server and is more of a specific feature of your server implementation. As mentioned above, it is possible but requires additional configuration.

I am going to close this issue, but feel free to continue to document your learnings for others here.

@smyrick smyrick closed this as completed Apr 20, 2020
@rharriso
Copy link
Contributor

I wanted to comment on how I was able to implement file uploading.

Note: I am using S3 for asset hosting

  1. Request pre-signed upload URL from graphQL service (Reject or grant URL based on user permissions)
  2. Upload asset directly to pre-signed URL from client (browser in my case)
  3. Include include URL in subsequent mutation. The back-end service can then access the uploaded file from the S3 bucket as neccessary.

This works well for me, since the GraphQL server is an API gateway and file processing is done by another service. This allows me to deliver reference the uploaded file when communicating between services, rather than passing a large binary blob that might not even be processed.

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

No branches or pull requests

5 participants