Skip to content

Commit

Permalink
fix(platform-fastify): await register call
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 10, 2020
1 parent 9ae49f6 commit d238ad4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/graphql.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class GraphQLModule implements OnModuleInit, OnModuleDestroy {
);
}

this.registerGqlServer(apolloOptions);
await this.registerGqlServer(apolloOptions);
if (this.options.installSubscriptionHandlers) {
this._apolloServer.installSubscriptionHandlers(
httpAdapter.getHttpServer(),
Expand All @@ -164,14 +164,14 @@ export class GraphQLModule implements OnModuleInit, OnModuleDestroy {
await this._apolloServer?.stop();
}

private registerGqlServer(apolloOptions: GqlModuleOptions) {
private async registerGqlServer(apolloOptions: GqlModuleOptions) {
const httpAdapter = this.httpAdapterHost.httpAdapter;
const platformName = httpAdapter.getType();

if (platformName === 'express') {
this.registerExpress(apolloOptions);
} else if (platformName === 'fastify') {
this.registerFastify(apolloOptions);
await this.registerFastify(apolloOptions);
} else {
throw new Error(`No support for current HttpAdapter: ${platformName}`);
}
Expand Down Expand Up @@ -207,7 +207,7 @@ export class GraphQLModule implements OnModuleInit, OnModuleDestroy {
this._apolloServer = apolloServer;
}

private registerFastify(apolloOptions: GqlModuleOptions) {
private async registerFastify(apolloOptions: GqlModuleOptions) {
const { ApolloServer } = loadPackage(
'apollo-server-fastify',
'GraphQLModule',
Expand All @@ -225,7 +225,8 @@ export class GraphQLModule implements OnModuleInit, OnModuleDestroy {
cors,
bodyParserConfig,
} = this.options;
app.register(

await app.register(
apolloServer.createHandler({
disableHealthCheck,
onHealthCheck,
Expand Down

0 comments on commit d238ad4

Please sign in to comment.