Skip to content

Disable "path", "locations" and "extensions" of "errors" object #2508

Answered by jasonbahl
realsamanrad asked this question in General
Discussion options

You must be logged in to vote

@samyrooster Hey, you can customize the error formatter by filtering the graphql_server_config like so:

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:

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jasonbahl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants