Ant*_*nac 6 node.js express graphql graphql-js apollo-server
我期待在我的apollo-server-express服务器上热重新加载我的GraphQL架构.任何人都会知道如何做到这一点?
我目前正在使用模式拼接来收集多个API的模式,但是我不希望每次这些模式更改时都必须重新启动我的应用程序.
我试图寻找快速路线并删除它,但这不起作用,我也尝试graphQLExpress()
再次在相同的路线上呼叫,并没有更新它.
谢谢你的帮助!
我深入研究了这个graphqlExpress
调用,它相当轻量级,只是使用提供的模式返回一个中间件函数。我能够通过包装它来确保它始终使用我的最新架构:
let schema = createSchema();
app.use('/graphql', bodyParser.json(), function(req, res, next) {
// ensure latest schema is always passed in, we'll reload it automatically
const graphql = graphqlExpress({ schema });
graphql(req, res, next);
});
Run Code Online (Sandbox Code Playgroud)
我目前正在使用本地/静态模式,因此文件观察器允许我schema
根据需要在此处进行更新。