5858use ApiPlatform \JsonApi \JsonSchema \SchemaFactory as JsonApiSchemaFactory ;
5959use ApiPlatform \JsonApi \Serializer \CollectionNormalizer as JsonApiCollectionNormalizer ;
6060use ApiPlatform \JsonApi \Serializer \EntrypointNormalizer as JsonApiEntrypointNormalizer ;
61+ use ApiPlatform \JsonApi \Serializer \ErrorNormalizer as JsonApiErrorNormalizer ;
6162use ApiPlatform \JsonApi \Serializer \ItemNormalizer as JsonApiItemNormalizer ;
6263use ApiPlatform \JsonApi \Serializer \ObjectNormalizer as JsonApiObjectNormalizer ;
6364use ApiPlatform \JsonApi \Serializer \ReservedAttributeNameConverter ;
@@ -297,7 +298,7 @@ public function register(): void
297298 });
298299
299300 $ this ->app ->extend (PropertyMetadataFactoryInterface::class, function (PropertyInfoPropertyMetadataFactory $ inner , Application $ app ) {
300- /** @var ConfigRepository */
301+ /** @var ConfigRepository $config */
301302 $ config = $ app ['config ' ];
302303
303304 return new CachePropertyMetadataFactory (
@@ -313,12 +314,12 @@ public function register(): void
313314 $ app ->make (ResourceClassResolverInterface::class)
314315 ),
315316 ),
316- true === $ config ->get ('app.debug ' ) ? 'array ' : ' file '
317+ true === $ config ->get ('app.debug ' ) ? 'array ' : $ config -> get ( ' cache.default ' , ' file ')
317318 );
318319 });
319320
320321 $ this ->app ->singleton (PropertyNameCollectionFactoryInterface::class, function (Application $ app ) {
321- /** @var ConfigRepository */
322+ /** @var ConfigRepository $config */
322323 $ config = $ app ['config ' ];
323324
324325 return new CachePropertyNameCollectionMetadataFactory (
@@ -331,7 +332,7 @@ public function register(): void
331332 )
332333 )
333334 ),
334- true === $ config ->get ('app.debug ' ) ? 'array ' : ' file '
335+ true === $ config ->get ('app.debug ' ) ? 'array ' : $ config -> get ( ' cache.default ' , ' file ')
335336 );
336337 });
337338
@@ -345,7 +346,7 @@ public function register(): void
345346
346347 // TODO: add cached metadata factories
347348 $ this ->app ->singleton (ResourceMetadataCollectionFactoryInterface::class, function (Application $ app ) {
348- /** @var ConfigRepository */
349+ /** @var ConfigRepository $config */
349350 $ config = $ app ['config ' ];
350351 $ formats = $ config ->get ('api-platform.formats ' );
351352
@@ -401,7 +402,7 @@ public function register(): void
401402 $ app ->make ('filters ' )
402403 )
403404 ),
404- true === $ config ->get ('app.debug ' ) ? 'array ' : ' file '
405+ true === $ config ->get ('app.debug ' ) ? 'array ' : $ config -> get ( ' cache.default ' , ' file ')
405406 );
406407 });
407408
@@ -907,6 +908,10 @@ public function register(): void
907908 return new ReservedAttributeNameConverter ($ app ->make (NameConverterInterface::class));
908909 });
909910
911+ if (interface_exists (FieldsBuilderEnumInterface::class)) {
912+ $ this ->registerGraphQl ($ this ->app );
913+ }
914+
910915 $ this ->app ->singleton (JsonApiEntrypointNormalizer::class, function (Application $ app ) {
911916 return new JsonApiEntrypointNormalizer (
912917 $ app ->make (ResourceMetadataCollectionFactoryInterface::class),
@@ -946,9 +951,11 @@ public function register(): void
946951 );
947952 });
948953
949- if (interface_exists (FieldsBuilderEnumInterface::class)) {
950- $ this ->registerGraphQl ($ this ->app );
951- }
954+ $ this ->app ->singleton (JsonApiErrorNormalizer::class, function (Application $ app ) {
955+ return new JsonApiErrorNormalizer (
956+ $ app ->make (JsonApiItemNormalizer::class),
957+ );
958+ });
952959
953960 $ this ->app ->singleton (JsonApiObjectNormalizer::class, function (Application $ app ) {
954961 return new JsonApiObjectNormalizer (
@@ -985,6 +992,7 @@ public function register(): void
985992 $ list ->insert ($ app ->make (JsonApiEntrypointNormalizer::class), -800 );
986993 $ list ->insert ($ app ->make (JsonApiCollectionNormalizer::class), -985 );
987994 $ list ->insert ($ app ->make (JsonApiItemNormalizer::class), -890 );
995+ $ list ->insert ($ app ->make (JsonApiErrorNormalizer::class), -790 );
988996 $ list ->insert ($ app ->make (JsonApiObjectNormalizer::class), -995 );
989997
990998 if (interface_exists (FieldsBuilderEnumInterface::class)) {
0 commit comments