How to customise mutation validation error messages
See original GitHub issueHi,
I’ve been trying to customise mutation validation errors but so far didn’t succeed in doing so, having the following query I would like to be able to return errors
if different shape
mutation CreateProject($projectName: String!, $description: String!) {
createProject(projectName: $projectName, description: $description) {
id
projectName
description
}
}
Standard errors look like
{
"errors": [
{
"message": "Variable \"$description\" of required type \"String!\" was not provided.",
"locations": [
{
"line": 1,
"column": 47
}
]
}
]
}
What I would like to have is
{
"errors": [
{
"$description": "Error message...",
"locations": [...]
}
}
So is it possible to adjust error response format?
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Validation and User Errors in GraphQL Mutations
The mutation code above validates the input by using validator.js library, builds an array of error messages and throws a custom error before...
Read more >Writing custom validations - Drupal Graphql - GitBook
Writing custom validations. One aspect that is important to consider when creating mutations is providing good error messages and validations.
Read more >Is it possible customize Hasura mutation/query Error messages?
My question is, is it possible to configure this error message? Because here, the role don't have the permission to do mutation. So...
Read more >Error handling - Apollo GraphQL Docs
Custom errors. You can create a custom errors and codes using the graphql package's GraphQLError class, like so: TypeScript.
Read more >Error messaging — Ariadne 0.1 documentation
Your first instinct when planning error messaging may be to use this approach to communicate custom errors (like permission or validation errors) raised...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking forward for the doc section regarding customization of error messages.
So I managed to make it and here is my solution
Custom view
Error formatter