I try to create a token using JWT and a GraphQL server
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. Thanks for any help in advance.
In this case, I go deep in apollo documentation and I have to return something like this.
authenticatedUser: (_, { input }) => {
const {email} = input;
const token = jwt.sign({ email }, process.env.SECRET_KEY, { expiresIn:'24h' });
return {token}
}
},
no like
return token
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.