【发布时间】:2020-01-08 16:33:57
【问题描述】:
我能够使用 Express 设置 Apollo GraphQL Server。
但是,Playground 无法正常工作。页面加载,但我尝试从 Playground 进行的所有查询都失败,并显示 HTTP 401 Unauthorized。
我的代码:
const server = new ApolloServer({
schema: MySchema,
context: ({ req }) => ({
connection: req.context.db,
auth: req.context.auth,
}),
playground: true,
});
// Add to Express
app.use(server.getMiddleware({ path: '/graphql' }));
Playground 在 localhost:4000/graphql 上运行,但是我进行的所有查询都以 HTTP 401 Unauthorized 失败。
【问题讨论】:
标签: express graphql apollo-server