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

Apollo koa integration #59

Merged
merged 5 commits into from
Jul 29, 2016
Merged

Apollo koa integration #59

merged 5 commits into from
Jul 29, 2016

Conversation

HriBB
Copy link
Contributor

@HriBB HriBB commented Jul 28, 2016

KoaJS apollo-server integration. All tests pass, but I still need to test it in a real-life application.

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

@apollo-cla
Copy link

@HriBB: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@helfer
Copy link
Contributor

helfer commented Jul 28, 2016

@HriBB First of all, thanks a lot for the PR!

It looks like all the tests pass, but there are still some linter errors that you should fix:

src/integrations/expressApollo.test.ts[28, 26]: block is empty
src/integrations/hapiApollo.test.ts[31, 26]: block is empty
src/integrations/koaApollo.test.ts[16, 10]: Unused import: 'OperationStore'
src/integrations/koaApollo.ts[2, 13]: Unused import: 'koaBody'

For the empty blocks, you can just make the destroyApp argument optional and not pass it from express and hapi tests.

I'll add comments about the code inline.

@@ -80,6 +84,7 @@ export default (createApp: CreateAppFunc) => {
query: 'query test{ testString }',
});
return req.then((res) => {
destroyApp(app);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did afterEach not work? That would be preferable to adding the call explicitly in every test, I think.

@HriBB
Copy link
Contributor Author

HriBB commented Jul 28, 2016

is this a good plan to introduce the alpha version of koa? will this alienate people who are using 1.x version of koa?

You are right, it's not a good plan, but I am not sure how to support both versions. Problem is that v2 uses a different syntax with async/await, where v1 uses generators/yield.

koa@1.x

app.use(function *(){
  this.body = 'Hello World';
});

koa@2.x

app.use(function(ctx){
  ctx.body = 'Hello World';
});

Not really sure how to tackle this. We could simply export two different versions such as apolloKoa and apolloKoa2. Not the best solution, but it could work, if there is a way to install both versions at once with npm. Is there?

@HriBB
Copy link
Contributor Author

HriBB commented Jul 28, 2016

@helfer and @nnance I removed all unnecessary tests, fixed linter issues, made destroyApp() optional and moved it into afterEach() mocha hook. Please check it out and let me know what you think.

@helfer
Copy link
Contributor

helfer commented Jul 28, 2016

@HriBB thanks, that looks great!

Regarding the use of Koa 2 vs. 1, I found this interesting Medium post: https://medium.com/@l1ambda/why-you-should-use-koa-with-node-js-7c231a8174fa#.8h6opnbvy

The tldr is that 2.0 alpha is considered stable, but they won't officially recommend it until Node has native support for async/await and Koa 2.0 can be used without Babel.

I'd say we land this PR as it is, and consider rewriting it for Koa 1 if there are many requests for it.

@helfer
Copy link
Contributor

helfer commented Jul 28, 2016

@HriBB can you update the Changelog to mention Koa support? The format should be something along the lines of

Once that's done, I can merge the PR, and I think we'll be ready to officially release the new apollo server tomorrow or on Monday!

@HriBB
Copy link
Contributor Author

HriBB commented Jul 29, 2016

@helfer done!

@HriBB
Copy link
Contributor Author

HriBB commented Jul 29, 2016

I hope I did not break anything with merging upstream ...

@helfer helfer merged commit 61ded20 into apollographql:master Jul 29, 2016
@helfer
Copy link
Contributor

helfer commented Jul 29, 2016

Perfect, merged!

trevor-scheer added a commit that referenced this pull request May 6, 2020
Use named exports instead of default so that composeAndValidate
is exported at the top level of the package.
trevor-scheer added a commit that referenced this pull request May 14, 2020
Use named exports instead of default so that composeAndValidate
is exported at the top level of the package.
@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.

None yet

3 participants