我在我的应用程序接口上有一个简单的graphQl实现,但似乎无法从解析器获得除args之外的任何其他参数。代码非常简单,所以应该不会引起任何问题:
const bindGraphqlModule = (app) => {
app.use(
"/graphql",
graphqlHTTP(() => {
return {
schema: graphQLSchema,
rootValue: resolvers,
context: {
test: "hi ?"
},
graphiql: process.env.NODE_ENV !== "production",
};
})
);
};然后我的解析器:
const resolver = async (args, context, test) => {
console.log(context, test);
const { email, password } = args;
...Args是可以正常访问的,但是context和test都是未定义的。有什么线索吗?
发布于 2021-11-17 15:37:43
我的错是,我实际上在一个函数中加入了解析器来处理错误,并且没有完全传递上下文。已解决
https://stackoverflow.com/questions/70003368
复制相似问题