mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 10:11:40 -05:00
Merge pull request #154 from HriBB/master
Pass ctx instead of ctx.request to koa options function
This commit is contained in:
commit
47fd535270
2 changed files with 3 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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}`;
|
||||
|
|
Loading…
Add table
Reference in a new issue