|
22 | 22 | use ApiPlatform\GraphQl\Type\TypesContainerInterface; |
23 | 23 | use ApiPlatform\JsonApi\Filter\SparseFieldset; |
24 | 24 | use ApiPlatform\JsonApi\Filter\SparseFieldsetParameterProvider; |
| 25 | +use ApiPlatform\Laravel\Controller\ApiPlatformController; |
25 | 26 | use ApiPlatform\Laravel\Eloquent\Extension\FilterQueryExtension; |
26 | 27 | use ApiPlatform\Laravel\Eloquent\Extension\QueryExtensionInterface; |
27 | 28 | use ApiPlatform\Laravel\Eloquent\Filter\BooleanFilter; |
|
42 | 43 | use ApiPlatform\Laravel\Eloquent\State\LinksHandlerInterface; |
43 | 44 | use ApiPlatform\Laravel\Eloquent\State\PersistProcessor; |
44 | 45 | use ApiPlatform\Laravel\Eloquent\State\RemoveProcessor; |
| 46 | +use ApiPlatform\Laravel\Exception\ErrorHandler; |
45 | 47 | use ApiPlatform\Laravel\Metadata\CacheResourceCollectionMetadataFactory; |
46 | 48 | use ApiPlatform\Laravel\Metadata\ParameterValidationResourceMetadataCollectionFactory; |
47 | 49 | use ApiPlatform\Laravel\State\ParameterValidatorProvider; |
48 | 50 | use ApiPlatform\Laravel\State\SwaggerUiProcessor; |
49 | 51 | use ApiPlatform\Laravel\State\ValidateProvider; |
| 52 | +use ApiPlatform\Metadata\IdentifiersExtractorInterface; |
50 | 53 | use ApiPlatform\Metadata\InflectorInterface; |
51 | 54 | use ApiPlatform\Metadata\Operation\PathSegmentNameGeneratorInterface; |
52 | 55 | use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface; |
|
80 | 83 | use ApiPlatform\State\Provider\ParameterProvider; |
81 | 84 | use ApiPlatform\State\Provider\SecurityParameterProvider; |
82 | 85 | use ApiPlatform\State\ProviderInterface; |
| 86 | +use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerInterface; |
83 | 87 | use Illuminate\Contracts\Foundation\Application; |
84 | 88 | use Illuminate\Contracts\Support\DeferrableProvider; |
85 | 89 | use Illuminate\Support\ServiceProvider; |
| 90 | +use Negotiation\Negotiator; |
86 | 91 | use Psr\Log\LoggerInterface; |
87 | 92 | use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; |
88 | 93 | use Symfony\Component\Serializer\NameConverter\NameConverterInterface; |
@@ -289,6 +294,26 @@ private function registerGraphQl(): void |
289 | 294 | $app->make(InflectorInterface::class) |
290 | 295 | ); |
291 | 296 | }); |
| 297 | + |
| 298 | + $this->app->singleton( |
| 299 | + ExceptionHandlerInterface::class, |
| 300 | + function (Application $app) { |
| 301 | + /** @var ConfigRepository */ |
| 302 | + $config = $app['config']; |
| 303 | + |
| 304 | + return new ErrorHandler( |
| 305 | + $app, |
| 306 | + $app->make(ResourceMetadataCollectionFactoryInterface::class), |
| 307 | + $app->make(ApiPlatformController::class), |
| 308 | + $app->make(IdentifiersExtractorInterface::class), |
| 309 | + $app->make(ResourceClassResolverInterface::class), |
| 310 | + $app->make(Negotiator::class), |
| 311 | + $config->get('api-platform.exception_to_status'), |
| 312 | + $config->get('app.debug'), |
| 313 | + $config->get('api-platform.error_formats') |
| 314 | + ); |
| 315 | + } |
| 316 | + ); |
292 | 317 | } |
293 | 318 |
|
294 | 319 | /** |
@@ -329,6 +354,7 @@ public function provides(): array |
329 | 354 | ResourceMetadataCollectionFactoryInterface::class, |
330 | 355 | 'api_platform.graphql.state_provider.parameter', |
331 | 356 | FieldsBuilderEnumInterface::class, |
| 357 | + ExceptionHandlerInterface::class, |
332 | 358 | ]; |
333 | 359 | } |
334 | 360 | } |
0 commit comments