Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Express 如何关闭graphql瑜伽服务器?_Express_Graphql Js_Prisma Graphql - Fatal编程技术网

Express 如何关闭graphql瑜伽服务器?

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()

对于express,在中进行了描述

但是在瑜伽的文献中

没有关于
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()