namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register()
{
// ...
// Register custom error formatting
\GraphQL::error(function ($error, $e) {
$previous = $e->getPrevious();
if ($previous && $previous instanceof \Nuwave\Lighthouse\Support\Exceptions\ValidationError) {
$error['status_code'] = 422;
}
return $error;
});
}
}