Skip to content

Commit b0c9e2b

Browse files
timble-oneTimo Bühlmann
authored andcommitted
graphql.md: add "MediaObject Normalization" chapter
graphql-normalizer needs to be injected
1 parent b3d08b5 commit b0c9e2b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

core/graphql.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,6 +2942,26 @@ 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 injected Normalizer must be replaced with the one from the
2948+
graphql-namespace:
2949+
2950+
```PHP
2951+
<?php
2952+
// api/src/Serializer/MediaObjectNormalizer.php
2953+
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+
) {}
2961+
2962+
...
2963+
```
2964+
29452965
### Using the `createMediaObject` Mutation
29462966

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

0 commit comments

Comments
 (0)