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

Get specific field validation error? #194

Open
danielmahon opened this issue Oct 28, 2016 · 0 comments
Open

Get specific field validation error? #194

danielmahon opened this issue Oct 28, 2016 · 0 comments

Comments

@danielmahon
Copy link

danielmahon commented Oct 28, 2016

Overview of the Issue

@tothandras Sorry to raise the dead (#66) but do you have a working example of how to get the individual field validation errors for a mutation? The only error graphql seems to give back is "modelName validation failed". I see where mongoose is calling that error but I can't find why it's calling THAT error and not the specific one for the field. Thanks for any help.

Reproduce the Error

GraphQL POST:

// my variables
{
  "input": {
    "name": ""
  }
}
// my mutation
mutation addModel($input: addModelInput!) {
  addModel(input: $input) {
    changedDepositionEdge {
      node {
        _id
        name
      }
    }
  }
}

Returns:

{
  "data": {
    "addModel": null
  },
  "errors": [
    {
      "message": "Model validation failed",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    }
  ]
}

Input schema(s):

...
  name: {
    type: Types.Text,
    initial: true,
    required: [true, 'Name is required!'],
    label: 'Display Name',
  },
...

Node version: 6.3.1
Graffiti-Mongoose version: 5.3.0

Related Issues

#66

Suggest a Fix

Does mongoose call multiple errors upon bad validation? Are we only checking for one?

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

1 participant