You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constbcrypt=require('bcryptjs')constjwt=require('jsonwebtoken')const{ Context, getUserId }=require('./utils')constAuthPayload={user: async({user: { id }},args,ctx,info)=>{returnctx.db.query.user({where: { id }},info)}}// query the currently logged in userfunctionme(parent,args,ctx,info){constid=getUserId(ctx)returnctx.db.query.user({where: { id }},info)}// register a new userasyncfunctionsignup(parent,args,ctx,info){constpassword=awaitbcrypt.hash(args.password,10)constuser=awaitctx.db.mutation.createUser({data: { ...args, password },})return{token: jwt.sign({userId: user.id},process.env.JWT_SECRET),
user,}}// log in an existing userasyncfunctionlogin(parent,{ email, password },ctx,info){constuser=awaitctx.db.query.user({where: { email }})if(!user){thrownewError(`No such user found for email: ${email}`)}constvalid=awaitbcrypt.compare(password,user.password)if(!valid){thrownewError('Invalid password')}return{token: jwt.sign({userId: user.id},process.env.JWT_SECRET),
user,}}module.exports={ me, signup, login, AuthPayload }
TypeError: Cannot read property 'getMutationType' of undefined
at Object.getTypeForRootFieldName (/Users/nburk/Projects/graphcool/docs/migration-example/1.0/myapp/node_modules/graphql-binding/dist/utils.js:25:45)
at buildInfoForAllScalars (/Users/nburk/Projects/graphcool/docs/migration-example/1.0/myapp/node_modules/graphql-binding/dist/info.js:17:24)
at Object.buildInfo (/Users/nburk/Projects/graphcool/docs/migration-example/1.0/myapp/node_modules/graphql-binding/dist/info.js:7:16)
at Proxy.<anonymous> (/Users/nburk/Projects/graphcool/docs/migration-example/1.0/myapp/node_modules/graphql-binding/dist/handler.js:15:27)
at signup (/Users/nburk/Projects/graphcool/docs/migration-example/1.0/myapp/src/auth.js:20:38)
at <anonymous>
The text was updated successfully, but these errors were encountered:
I'm trying to produce a simple auth example, you can find the full repo here.
The project is setup as follows:
index.js
schema.graphql
auth.js
utils.js
I am getting an error when sending the
signup
mutation:This is the full error message:
The text was updated successfully, but these errors were encountered: