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

Add failing test for file upload #87

Merged
merged 1 commit into from
Aug 8, 2016

Conversation

HriBB
Copy link
Contributor

@HriBB HriBB commented Aug 7, 2016

OK I hope I did it right this time.

I only added a failing test for file upload. @helfer let me know if it is OK ;)

TODO:

  • Update CHANGELOG.md with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

@helfer helfer merged commit 5484fad into apollographql:file-upload Aug 8, 2016
@helfer
Copy link
Contributor

helfer commented Aug 8, 2016

Awesome, merged!

@HriBB HriBB deleted the file-upload branch August 8, 2016 20:20
@HriBB HriBB restored the file-upload branch August 8, 2016 20:21
@HriBB
Copy link
Contributor Author

HriBB commented Aug 8, 2016

@helfer great! So what's next?

I already have a working file upload implementation for koa using async-busboy, which uses raw http request. I could create fileUpload() module, which we can use in all integrations. Anyway, let me know how to proceed ;)

@helfer
Copy link
Contributor

helfer commented Aug 8, 2016

Yeah, if you could make a module that can be used by all integrations, that would be great in theory, but in practice each server uses a different way to handle file uploads. HAPI has it built-in, I believe, while with Express you have to parse the request yourself using the appropriate module.

Because each server handles it differently, we decided not to handle the request parsing in apollo server. If possible, we should keep it that way for file uploads as well. So instead of adding a new dependency, you should see if you can get the tests to pass. For express, I think it would be enough to provide the right arguments to body parser. If that works for Koa and HAPI as well, then we don't actually need to make any modifications to apollo-server's core or integrations. Then all you have to do is to set up the right request parsing for each server so they can pass the test. If it's not possible to have a common setup for all of them, then maybe we need to split out the file upload test and do it separately for each integration.

Do you think that makes sense?

@nnance Do you know how file uploading works in HAPI? Would it be easy to get the current file upload test to pass without major modifications to how we set up the tests for each server?

@HriBB
Copy link
Contributor Author

HriBB commented Aug 8, 2016

I think I understand what you mean. I am no expert in this field, but I believe it should be possible with the right body parser, at least for express and koa. Maybe we can extract the logic into a custom middleware? Then users could do something like app.use(koaApolloUpload(options)).

I will play with this when I find some spare time. It's cool, because I am currently working on two different apps and one uses apolloExpress and the other one apolloKoa :)

@helfer
Copy link
Contributor

helfer commented Aug 8, 2016

Haha, nice! I think the main thing we have to do is figure out how to make it work. If it's simple enough (i.e. just a few lines of code), then I think we shouldn't write a middleware for it, because that will a) limit what people can do and b) require us to keep it up to date, which doesn't seem worth it given the minimal thing it adds.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants