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

Handle file uploads over GraphQL #7

Open
f opened this issue Feb 21, 2017 · 3 comments
Open

Handle file uploads over GraphQL #7

f opened this issue Feb 21, 2017 · 3 comments
Assignees

Comments

@f
Copy link
Owner

f commented Feb 21, 2017

Add file upload handling.

@f f added the enhancement label Feb 21, 2017
@f f self-assigned this Feb 21, 2017
@mraak
Copy link

mraak commented Jul 21, 2017

Is there a workaround for this? I'd like to send a file at the same time I'm sending data.

@flewellyn
Copy link

Most likely the way to proceed would be to use the FormData API in the internal __request method. This would take care of the content type headers, so you would need to modify the internals to not use x-www-form-urlencoded as the content-type. In fact, with FormData, you're better off not setting content-type at all.

Once that's done, you'd need to work out a protocol in your code for adding files and referring to them in the variables of a mutation. One possibility is having the input fields in the mutation input refer to the file input, such that each file input would have the same key in the form input that you used as a value in the mutation input field. Then the server would need to know to decode this and match up the values; that's a matter for your server-side resolvers to figure out.

That's how I'm trying to proceed, anyway.

@kemalturk
Copy link

kemalturk commented Jul 7, 2019

In my projects im converting image to Base64 format and im sending it in normal mutation query.
But in this approach you should change request limit on your server. And of course you need to convert Base64 format to file on server side. Okay this approach is difficult but its flexible. You can send multiple images and other datas in one request.

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

No branches or pull requests

4 participants