Skip to content

Commit

Permalink
fix(typing): type ContextFunction params separately from resulting co…
Browse files Browse the repository at this point in the history
…ntext object
  • Loading branch information
cheapsteak committed Feb 21, 2019
1 parent d05212e commit d08569e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/apollo-server-core/src/types.ts
Expand Up @@ -29,10 +29,10 @@ export { GraphQLSchemaModule };

export { KeyValueCache } from 'apollo-server-caching';

export type ContextFunction<T = any> = (
context: Context<T>,
) => Context<T> | Promise<Context<T>>;
export type Context<T = object> = T;
export type ContextFunction<FunctionParams = any, ContextContent = object> = (
context: FunctionParams,
) => Context<ContextContent> | Promise<Context<ContextContent>>;

// A plugin can return an interface that matches `ApolloServerPlugin`, or a
// factory function that returns `ApolloServerPlugin`.
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-express/src/ApolloServer.ts
Expand Up @@ -77,7 +77,7 @@ interface ExpressContext {

export interface ApolloServerExpressConfig extends Config {
cors?: CorsOptions | boolean;
context?: ContextFunction<ExpressContext> | Context<ExpressContext>;
context?: ContextFunction<ExpressContext, Context> | Context;
}

export class ApolloServer extends ApolloServerBase {
Expand Down

0 comments on commit d08569e

Please sign in to comment.