Skip to content

Commit

Permalink
feat(server): context may return a promise
Browse files Browse the repository at this point in the history
Closes: #74
  • Loading branch information
enisdenjo committed Nov 15, 2020
1 parent ec1b461 commit cd5c2f8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export interface ServerOptions {
ctx: Context,
message: SubscribeMessage,
args: ExecutionArgs,
) => GraphQLExecutionContextValue);
) =>
| Promise<GraphQLExecutionContextValue>
| GraphQLExecutionContextValue);
/**
* The GraphQL root fields or resolvers to go
* alongside the schema. Learn more about them
Expand Down Expand Up @@ -641,7 +643,7 @@ export function createServer(
if (!('contextValue' in execArgs)) {
execArgs.contextValue =
typeof context === 'function'
? context(ctx, message, execArgs)
? await context(ctx, message, execArgs)
: context;
}

Expand Down

0 comments on commit cd5c2f8

Please sign in to comment.