Skip to content

Commit ec0c2df

Browse files
graphql.md: add "MediaObject Normalization" chapter
optimization from @vinceAmstoutz Co-authored-by: Vincent Amstoutz <[email protected]>
1 parent 0ba5db7 commit ec0c2df

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

core/graphql.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,20 +2947,23 @@ For handling the upload of multiple files, iterate over `$context['args']['input
29472947
In the constructor of the `MediaObjectNormalizer`, the injected Normalizer must be replaced with the one from the
29482948
`api_platform.graphql.normalizer.item` from GraphQL:
29492949

2950-
```PHP
2950+
```php
29512951
<?php
29522952
// api/src/Serializer/MediaObjectNormalizer.php
29532953
2954-
...
2955-
2956-
public function __construct(
2957-
#[Autowire(service: 'api_platform.graphql.normalizer.item')]
2958-
private readonly NormalizerInterface $normalizer,
2959-
private readonly StorageInterface $storage
2960-
) {}
2954+
use App\Storage\StorageInterface;
2955+
use ApiPlatform\GraphQl\Serializer\ItemNormalizer;
29612956
2962-
...
2963-
```
2957+
final readonly class MediaObjectNormalizer
2958+
{
2959+
public function __construct(
2960+
#[Autowire(service: ItemNormalizer::class)]
2961+
private NormalizerInterface $normalizer,
2962+
private StorageInterface $storage
2963+
) {}
2964+
2965+
// ...
2966+
}
29642967
29652968
### Using the `createMediaObject` Mutation
29662969

0 commit comments

Comments
 (0)