[英]Mutation token all way return a null Graphql
我嘗試使用 JWT 和 GraphQL 服務器創建令牌
但是當我嘗試進行咨詢時:
mutation authenticatedUser($input:authenticatedUserInput){
authenticatedUser(input:$input){
token
}
}
我只是得到這個:
{
"data": {
"authenticatedUser": {
"token": null
}
}
}
這就是我使用服務器的方式:
const server = new ApolloServer({
typeDefs,
resolvers,
})
我在這里做錯了什么? 我是 GraphQL 的新手。 感謝您提前提供任何幫助。
在這種情況下,我 go 深入阿波羅文檔,我必須返回類似的內容。
authenticatedUser: (_, { input }) => {
const {email} = input;
const token = jwt.sign({ email }, process.env.SECRET_KEY, { expiresIn:'24h' });
return {token}
}
},
不喜歡
return token
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.