Skip to content

Commit

Permalink
graphql.md: add "MediaObject Normalization" chapter
Browse files Browse the repository at this point in the history
graphql-normalizer needs to be injected
  • Loading branch information
71m024 committed Dec 14, 2024
1 parent 162eae7 commit 0c170e2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions core/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,25 @@ final class CreateMediaObjectResolver implements MutationResolverInterface

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

### Normalization of MediaObjects

In the constructor of the `MediaObjectNormalizer`, the GraphQL Normalizer must be injected:

```PHP
<?php
// api/src/Serializer/MediaObjectNormalizer.php
...
public function __construct(
#[Autowire(service: 'api_platform.graphql.normalizer.item')]
private readonly NormalizerInterface $normalizer,
private readonly StorageInterface $storage
) {}
...
```

### Using the `createMediaObject` Mutation

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

0 comments on commit 0c170e2

Please sign in to comment.