Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return better mongoose errors #66

Closed
voronianski opened this issue Nov 29, 2015 · 5 comments
Closed

Return better mongoose errors #66

voronianski opened this issue Nov 29, 2015 · 5 comments

Comments

@voronianski
Copy link

For example I have model with required field:

import mongoose from 'mongoose';

const UserSchema = new mongoose.Schema({
    email: {
        type: String,
        unique: true,
        trim: true,
        required: 'Email is required'
    },

    createdAt: {
        type: Date,
        default: Date.now
    }
});

const User = mongoose.model('User', UserSchema);

export default User;

but when I send mutation to server like {"mutation { addUser(input: {clientMutationId: "1"}) { clientMutationId } }"} I receive not well enough descriptive error:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "User validation failed"
}
@tothandras
Copy link
Contributor

Hi @voronianski! The error messages are not specified by graffiti-mongoose. An error message could come either from Mongoose or from GraphQL itself (caught exception for example).

@voronianski
Copy link
Author

@tothandras it's mongoose error but it should be overwritten with 'Email is required' message specified in mongoose schema, what version of mongoose do you use?

@tothandras
Copy link
Contributor

@voronianski 4.2.8

@tothandras
Copy link
Contributor

@voronianski anything else? Can we do something to improve the error messages?

@voronianski
Copy link
Author

@tothandras sorry I don't have time to investigate it now, will close it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants