Skip to content

Commit 6563b77

Browse files
authored
await appoloServer to stop, before starting a new one
1 parent c436ec9 commit 6563b77

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/service.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,14 @@ module.exports = function (mixinOptions) {
607607
/**
608608
* Prepare GraphQL schemas based on Moleculer services.
609609
*/
610-
prepareGraphQLSchema() {
610+
async prepareGraphQLSchema() {
611611
// Schema is up-to-date
612612
if (!this.shouldUpdateGraphqlSchema && this.graphqlHandler) {
613613
return;
614614
}
615-
615+
616616
if (this.apolloServer) {
617-
this.apolloServer.stop();
617+
await this.apolloServer.stop();
618618
}
619619

620620
// Create new server & regenerate GraphQL schema
@@ -734,17 +734,17 @@ module.exports = function (mixinOptions) {
734734

735735
const route = _.defaultsDeep(mixinOptions.routeOptions, {
736736
aliases: {
737-
"/"(req, res) {
737+
async "/"(req, res) {
738738
try {
739-
this.prepareGraphQLSchema();
739+
await this.prepareGraphQLSchema();
740740
return this.graphqlHandler(req, res);
741741
} catch (err) {
742742
this.sendError(req, res, err);
743743
}
744744
},
745-
"GET /.well-known/apollo/server-health"(req, res) {
745+
async "GET /.well-known/apollo/server-health"(req, res) {
746746
try {
747-
this.prepareGraphQLSchema();
747+
await this.prepareGraphQLSchema();
748748
} catch (err) {
749749
res.statusCode = 503;
750750
return this.sendResponse(
@@ -783,8 +783,8 @@ module.exports = function (mixinOptions) {
783783
query: { type: "string" },
784784
variables: { type: "object", optional: true },
785785
},
786-
handler(ctx) {
787-
this.prepareGraphQLSchema();
786+
async handler(ctx) {
787+
await this.prepareGraphQLSchema();
788788
return GraphQL.graphql(
789789
this.graphqlSchema,
790790
ctx.params.query,

0 commit comments

Comments
 (0)