Skip to content

Commit

Permalink
Move TContext generic from requestDidStart method to ApolloServerPlug…
Browse files Browse the repository at this point in the history
…in Interface (#3525)

This commit provides a new type variable to the `ApolloServerPlugin` interface
to support the typing of the `context` variable throughout the lifecycle hooks.
Previously, `requestDidStart` was typed in such a way that the `TContext` typing
wasn't actually useful.

This fix is backwards-compatible for current implementors as it provides a default
type to the newly introduced type variable on the `ApolloServerPlugin` interface.
  • Loading branch information
jdmoody authored and trevor-scheer committed Dec 9, 2019
1 parent 458d50c commit 9e1f54a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/apollo-server-plugin-base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export {
WithRequired,
};

export interface ApolloServerPlugin {
export interface ApolloServerPlugin<TContext extends Record<string, any> = Record<string, any>> {
serverWillStart?(service: GraphQLServiceContext): ValueOrPromise<void>;
requestDidStart?<TContext>(
requestDidStart?(
requestContext: GraphQLRequestContext<TContext>,
): GraphQLRequestListener<TContext> | void;
}
Expand Down

0 comments on commit 9e1f54a

Please sign in to comment.