如何在不重新启动服务的情况下更新架构




我的程序使用apollo服务器koa作为graphql服务,我想动态更新模式。例如:
-当用户将数据上传到服务器时,架构也需要更新,但不需要重新启动服务
我读过模式转换和模式缝合,但它们不符合我的要求
任何人都可以给我一个建议
非常感谢!

我用apollo-server-express@1.3.2.我还没有转换到2,我也没有做koa,但我想大致相同。如果没有,希望至少能有所帮助。

const { graphqlExpress } = require('apollo-server-express')
let schema = loadRemoteSchemas() // this loads it on start-up
app.use(async (req, res) => {
return {
schema: await schema,
}
}
app.use('refresh', async (req, res) => {
// some middleware that does stuff and changes the `schema` pointer
})

最新更新