Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphql.md: add "MediaObject Normalization" chapter #2109

Open
wants to merge 1 commit into
base: 4.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading