Update signature to enable responses to be used in the middleware.

This commit is contained in:
John Barela
2018-03-09 14:31:21 -07:00
parent 8342528052
commit e712c102ad
2 changed files with 3 additions and 3 deletions

View File

@@ -14,13 +14,13 @@ const graphqlOption: graphqlHTTP.OptionsObj = {
extensions: (args) => { }
};
const graphqlOptionRequest = (request: express.Request): graphqlHTTP.OptionsObj => ({
const graphqlOptionRequest = (request: express.Request, response: express.Response): graphqlHTTP.OptionsObj => ({
graphiql: true,
schema: schema,
context: request.session
});
const graphqlOptionRequestAsync = async (request: express.Request): Promise<graphqlHTTP.OptionsObj> => {
const graphqlOptionRequestAsync = async (request: express.Request, response: express.Response): Promise<graphqlHTTP.OptionsObj> => {
return {
graphiql: true,
schema: await Promise.resolve(schema),

View File

@@ -16,7 +16,7 @@ declare namespace graphqlHTTP {
* Used to configure the graphQLHTTP middleware by providing a schema
* and other configuration options.
*/
export type Options = ((req: Request) => OptionsObj) | ((req: Request) => Promise<OptionsObj>) | OptionsObj
export type Options = ((req: Request, res: Response) => OptionsObj) | ((req: Request, res: Response) => Promise<OptionsObj>) | OptionsObj
export type OptionsObj = {
/**
* A GraphQL schema from graphql-js.