January 2019
Intermediate to advanced
460 pages
10h 33m
English
You should now be familiar with creating new mutations. First, edit the schema to accept the new mutation:
signup ( username: String! email: String! password: String!): Auth
We only need the username, email, and password properties that were mentioned in the preceding code to accept new users. If your application requires a gender or something else, you can add it here. When trying to sign up, we need to ensure that neither the email address nor the username is already taken. You can copy over the code to implement the resolver for signing up new users:
signup(root, { email, password, username }, context) { return User.findAll({ where: { [Op.or]: [{email}, {username}] }, raw: true, }).then(async (users) => { if(users.length) ...Read now
Unlock full access