Skip to content

Commit 0c170e2

Browse files
committed
graphql.md: add "MediaObject Normalization" chapter
graphql-normalizer needs to be injected
1 parent 162eae7 commit 0c170e2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

core/graphql.md

+19
Original file line numberDiff line numberDiff line change
@@ -2942,6 +2942,25 @@ final class CreateMediaObjectResolver implements MutationResolverInterface
29422942

29432943
For handling the upload of multiple files, iterate over `$context['args']['input']['files']`.
29442944

2945+
### Normalization of MediaObjects
2946+
2947+
In the constructor of the `MediaObjectNormalizer`, the GraphQL Normalizer must be injected:
2948+
2949+
```PHP
2950+
<?php
2951+
// api/src/Serializer/MediaObjectNormalizer.php
2952+
2953+
...
2954+
2955+
public function __construct(
2956+
#[Autowire(service: 'api_platform.graphql.normalizer.item')]
2957+
private readonly NormalizerInterface $normalizer,
2958+
private readonly StorageInterface $storage
2959+
) {}
2960+
2961+
...
2962+
```
2963+
29452964
### Using the `createMediaObject` Mutation
29462965

29472966
Following the specification, the upload must be done with a `multipart/form-data` content type.

0 commit comments

Comments
 (0)