我正在尝试获取apollo-server-lambda
或apollo-server-express
使用 v3.36 的可执行模式。
以下是我们使用的包:
apollo-server-express@3.36 or apollo-server-lambda@3+
graphql-constraint-directive@3.0.0
@graphql-tools/schema@7.1.3
我进行了多重回归测试以使其正常工作,但它似乎没有达到 GraphQL。
这是我的 Apollo 服务器配置:
const apolloServer = new ApolloServer({
schema: initializeSchema(),
plugins: [
ApolloServerPluginLandingPageGraphQLPlayground(),
{
didEncounterErrors(errors) {
logger.info(`didEncounterErrors:`)
logger.info(errors)
},
async requestDidStart(requestContext) {
logger.info(`Request started! ${requestContext}`);
return {
async parsingDidStart(requestContext) {
logger.info(`Parsing started! ${requestContext}`);
},
async validationDidStart(requestContext) {
logger.info(`Validation started! ${requestContext}`);
}
}
},
}],
context: async ({ event, context, express }) => {
logger.info(`Loading event... ${JSON.stringify(event)}`)
const newContext = {
headers: event.headers,
functionName: context.functionName,
event,
context,
expressRequest: express.req,
user: {} ?? null,
}
logger.info(`context ${JSON.stringify(newContext)}`)
return newContext
},
dataSources: () => {
logger.info('!initializing datasource')
initializeDbConnection()
return {}
},
...(['staging', 'production', 'demo'].includes(process.env.stage as string)
? { introspection: false, playground: false }
: {}),
})
我能够在 initializeSchema 中记录可执行模式,但升级后它似乎没有命中 GraphQL Typedef 和 Resolver。它直接进入上下文。所以,我有点难过如何使 HTTP 请求使用 Typedef 和 ResolversmakeExecutableSchema()
我只需要一些建议或表格列表来帮助我哪个版本最适合给定的apollo-server-<server_version>
.