Search code examples
graphqlrelayjsgraphql-js

Cannot set property 'clientMutationId' of undefined" Error


outputFields: {
    token: {
        type: GraphQLString,
        resolve: (token) => token
    }
},

outputfields never gets called, not sure whether i am doing in a right way or not, doesn't the resolve function gets called while returning data from mutateAndGetPayload method.

mutateAndGetPayload: (credentials) => {
    console.log('credentials', credentials);
    userprof.findOne({email: credentials.email}).exec(function(err, r) {
        if(!r) {
            return new Error('no user')
        } else if(r) {
            if(r.password != credentials.password) {
                return new Error('password error');
            } else {
                var token = jwt.getToken(r);
                console.log(token);
                return {token};
            }
        }
    });
}

Solution

  • I think that you need to return something from the mutateAndGetPayload method. That could be a promise. Try to return the userprof.findOne.