Express 如何关闭graphql瑜伽服务器?
对于express,在中进行了描述 但是在瑜伽的文献中 没有关于Express 如何关闭graphql瑜伽服务器?,express,graphql-js,prisma-graphql,Express,Graphql Js,Prisma Graphql,对于express,在中进行了描述 但是在瑜伽的文献中 没有关于close方法的信息 更新 @perdox的解决方案解决了我的问题,正确答案是: const gqlServer = new GraphQLServer({ typeDefs, resolvers }); const server = gqlServer.start(() => console.log('Server is running on localhost:4000')); (async function f()
close
方法的信息
更新 @perdox的解决方案解决了我的问题,正确答案是:
const gqlServer = new GraphQLServer({ typeDefs, resolvers });
const server = gqlServer.start(() => console.log('Server is running on localhost:4000'));
(async function f() {
(await server).close();
})();
GraphQLYoga是一组工具,使用/包装express服务器 见: 因此,正如您在源代码中看到的,GraphQLServer包装了express服务器,start方法返回HttpServer承诺。因此,您应该能够通过调用HttpServer上的close方法来关闭服务器:
const gqlServer = new GraphQLServer({ typeDefs, resolvers })
const server = gqlServer.start(() => console.log('Server is running on localhost:4000'))
server.close()