Merge pull request #154 from HriBB/master

Pass ctx instead of ctx.request to koa options function
This commit is contained in:
Jonas Helfer 2016-10-01 00:52:20 -07:00 committed by GitHub
commit 47fd535270
2 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,7 @@
# Changelog
### VNEXT
* Pass `ctx` instead of `ctx.request` to options function in Koa integration ([@HriBB](https://github.com/HriBB)) in [PR #154](https://github.com/apollostack/apollo-server/pull/154)
### v0.3.2
* Added missing exports for hapi integration ([@nnance](https://github.com/nnance)) in [PR #152](https://github.com/apollostack/apollo-server/pull/152)

View file

@ -5,7 +5,7 @@ import ApolloOptions from './apolloOptions';
import * as GraphiQL from '../modules/renderGraphiQL';
export interface KoaApolloOptionsFunction {
(req: koa.Request): ApolloOptions | Promise<ApolloOptions>;
(ctx: koa.Context): ApolloOptions | Promise<ApolloOptions>;
}
export interface KoaHandler {
@ -25,7 +25,7 @@ export function apolloKoa(options: ApolloOptions | KoaApolloOptionsFunction): Ko
let optionsObject: ApolloOptions;
if (isOptionsFunction(options)) {
try {
optionsObject = await options(ctx.request);
optionsObject = await options(ctx);
} catch (e) {
ctx.status = 500;
return ctx.body = `Invalid options provided to ApolloServer: ${e.message}`;