github nuwave/lighthouse v2.1-beta.2
Allow custom error formatting

latest releases: v6.45.0, v6.44.2, v6.44.1...
pre-release6 years ago
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;
        });
    }
}

Don't miss a new lighthouse release

NewReleases is sending notifications on new releases.