Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// src/resolvers/Mutation.js
const bcrypt = require('bcryptjs')
const jwt = require('jsonwebtoken')
const { APP_SECRET, getUserId } = require('../utils')
async function signup(parent, args, context, info) {
const hashedPass = await bcrypt.hash(args.password, 10)
const {password, ...user} = await context.prisma.createUser({ ...args, password: hashedPass })
const token = jwt.sign({ userId: user.id }, APP_SECRET)
return {
token,
user,
}
}
module.exports = {
signup
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.