[尝试时:
const server = new ApolloServer({
schema: schema,
context: { req, driver, neo4jDatabase: process.env.NEO4J_DATABASE },
introspection: true,
playground: true,
})
错误:未定义请求
以及尝试时:
const server = new ApolloServer({
schema: schema,
context: ({ res }, driver, neo4jDatabase = process.env.NEO4J_DATABASE) => (
res, driver, neo4jDatabase
),
introspection: true,
playground: true,
})
错误:未提供Neo4j JavaScript驱动程序实例。
我已经尝试了许多不同的方式编写和阅读Apollo源代码,但没有成功。
感谢此评论https://github.com/grand-stack/graphql-auth-directives/issues/4#issuecomment-494620480解决了>
const server = new ApolloServer({
schema,
context: ({ req }) => {
return {
headers: req.headers,
driver
};
}
});