Disable "path", "locations" and "extensions" of "errors" object #2508
Answered
by
jasonbahl
realsamanrad
asked this question in
General
-
The current {
"errors": [
{
"message": "The ID input is invalid. Make sure you set the proper idType for your input.",
"extensions": {
"category": "user"
},
"locations": [
{
"line": 2,
"column": 5
}
],
"path": [
"post"
]
}
],
} Is there any filter/action to remove the |
Beta Was this translation helpful? Give feedback.
Answered by
jasonbahl
Sep 21, 2022
Replies: 1 comment
-
@samyrooster Hey, you can customize the error formatter by filtering the add_filter( 'graphql_server_config', function( $config ) {
// This overrides the error to only return a message (not the locations/path)
$config->setErrorFormatter(function ($error){
return [ 'message' => $error->getMessage() ];
});
// you can customize the debug flag as well, if you want to get rid of the trace and only show the debug message
$config->setDebugFlag( GraphQL\Error\DebugFlag::INCLUDE_DEBUG_MESSAGE );
return $config;
} ); Before adding this snippet:After: |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jasonbahl
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@samyrooster Hey, you can customize the error formatter by filtering the
graphql_server_config
like so:Before adding this snippet:
After: