[英]Mutation token all way return a null Graphql
I try to create a token using JWT and a GraphQL server我尝试使用 JWT 和 GraphQL 服务器创建令牌
I just have this resolver.我只有这个解析器。
But when I try to do the consults:但是当我尝试进行咨询时:
mutation authenticatedUser($input:authenticatedUserInput){
authenticatedUser(input:$input){
token
}
}
I just get this:我只是得到这个:
{
"data": {
"authenticatedUser": {
"token": null
}
}
}
This is how I am using the server:这就是我使用服务器的方式:
const server = new ApolloServer({
typeDefs,
resolvers,
})
What I am doing wrong here?我在这里做错了什么? I am new to GraphQL.
我是 GraphQL 的新手。 Thanks for any help in advance.
感谢您提前提供任何帮助。
In this case, I go deep in apollo documentation and I have to return something like this.在这种情况下,我 go 深入阿波罗文档,我必须返回类似的内容。
authenticatedUser: (_, { input }) => {
const {email} = input;
const token = jwt.sign({ email }, process.env.SECRET_KEY, { expiresIn:'24h' });
return {token}
}
},
no like不喜欢
return token
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.