refactor (graphql.js): Upgrade to the v2 of apollo #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We used to get the 'graphqlKoa' and 'graphiqlKoa' before as the middle-wares, but now they have been either removed or hidden from the public. And since v2 of apollo we've faced with a BREAKING CHANGE (See:apollographql/apollo-server@dbaa465#diff-64af8fdf76996fa3ed4e498d44124800).
In order to be compatible with the older codes users are referring,
we have to do some tricks:
Directly refer 'graphqlKoa' from 'apollo-server-koa/dist/koaApollo' instead
of 'apollo-server-koa', because it's NOT exposed through 'index.js'.
'apollo-server-module-graphiql' is removed, so in order to compatible with
what it was, we have to add this in our package and reuse that. And then we should
rewrite 'graphiqlKoa' function as the middle-ware copied from: https://github.com/apollographql/apollo-server/blob/300c0cd12b56be439b206d55131e1b93a9e6dade/packages/apollo-server-koa/src/koaApollo.ts#L51
Notice: This change is also a BREAKING one, so please DO NOT apply to apollo's
version that is less than 2.x. And there're many ambigious problems about this
design of v2 for apollo (See: apollographql/apollo-server#1308).
So according to chentsulin's ideas, maybe the middle-ware functions would be re-added
in the future (See: apollographql/apollo-server#1282 (comment)).
npm test
passesRef: eggjs/egg#2862