-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: 2.7 and 3.0 metadata system #1519
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
Conversation
#[ApiResource] | ||
#[Query] | ||
#[Mutation(name: 'create')] | ||
#[ApiResource(graphQlOperations: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using graphQlOperations
?
core/dto.md
Outdated
|
||
However, it's sometimes useful to use a specific class to represent the input or output data structure related to an operation. | ||
|
||
## Specifying an Input or an Output Data Representation | ||
## Implementing a write operation with an input different from the resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Implementing a write operation with an input different from the resource | |
## Implementing a Write Operation With an Input Different From the Resource |
core/dto.md
Outdated
|
||
```php | ||
<?php | ||
// api/src/Model/UserResetPasswordDto.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// api/src/Model/UserResetPasswordDto.php | |
// api/src/Model/User.php |
core/dto.md
Outdated
throw new NotFoundHttpException(); | ||
} | ||
|
||
public function resumable(?string $operationName = null, array $context = []): bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function resumable(?string $operationName = null, array $context = []): bool { | |
public function resumable(?string $operationName = null, array $context = []): bool | |
{ |
core/dto.md
Outdated
} | ||
``` | ||
|
||
## Implementing a read operation with an output different from the resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Implementing a read operation with an output different from the resource | |
## Implementing a Read Operation With an Output Different From the Resource |
core/dto.md
Outdated
|
||
final class BookRepresentationProvider implements ProviderInterface | ||
{ | ||
public function provide(string $resourceClass, array $identifiers = [], ?string $operationName = null, array $context = []) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function provide(string $resourceClass, array $identifiers = [], ?string $operationName = null, array $context = []) { | |
public function provide(string $resourceClass, array $identifiers = [], ?string $operationName = null, array $context = []) | |
{ |
core/identifiers.md
Outdated
return $resourceClass === Person::class; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} |
core/identifiers.md
Outdated
public function supports(string $resourceClass, array $identifiers = [], ?string $operationName = null, array $context = []): bool | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function supports(string $resourceClass, array $identifiers = [], ?string $operationName = null, array $context = []): bool | |
{ | |
public function supports(string $resourceClass, array $identifiers = [], ?string $operationName = null, array $context = []): bool | |
{ |
core/identifiers.md
Outdated
} | ||
``` | ||
|
||
To cover this use case, we need to `denormalize` the identifier to an instance of our `App\Uuid` class. This case is covered by an identifier denormalizer: | ||
To cover this use case, we need to `convert` the identifier to an instance of our `App\Uuid` class. This case is covered by an uri variable transformer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To cover this use case, we need to `convert` the identifier to an instance of our `App\Uuid` class. This case is covered by an uri variable transformer: | |
To cover this use case, we need to `transform` the identifier to an instance of our `App\Uuid` class. This case is covered by an uri variable transformer: |
core/identifiers.md
Outdated
|
||
/** | ||
* {@inheritdoc} | ||
* Checks whether the given class is supported for denormalization by this normalizer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Checks whether the given class is supported for denormalization by this normalizer. | |
* Checks whether the given uri variable is supported for transformation by this transformer. |
core/identifiers.md
Outdated
{ | ||
/** | ||
* {@inheritdoc} | ||
* Denormalizes data back into an object of the given class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Denormalizes data back into an object of the given class. | |
* Transforms a uri variable value. |
core/security.md
Outdated
@@ -343,4 +347,4 @@ section. | |||
|
|||
## Changing Serialization Groups Depending of the Current User | |||
|
|||
See [how to dynamically change](serialization.md#changing-the-serialization-context-dynamically) the current Serializer context according to the current logged in user. | |||
See [how |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
core/subresources.md
Outdated
The starting point of a subresource must be a relation on an existing resource. | ||
For example, let's create two entities (Question, Answer) and set up a subresource so that `/question/42/answer` gives us | ||
the answer to the question 42: | ||
## URI variables configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## URI variables configuration | |
## URI Variables Configuration |
core/subresources.md
Outdated
In the previous examples, the `method` attribute is mandatory, because the operation name doesn't match a supported HTTP | ||
method. | ||
In this example, we instructed API Platform that the `Answer` we retrieve comes **from** the **class** `Question` | ||
**from** the **propety** `answer` of that class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**from** the **propety** `answer` of that class. | |
**from** the **property** `answer` of that class. |
core/subresources.md
Outdated
``` | ||
|
||
### Access Control of Subresources | ||
### Company employee's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Company employee's | |
### Company Employee's |
core/subresources.md
Outdated
|
||
You can control depth of subresources with the parameter `maxDepth`. For example, if the `Answer` entity also has a subresource | ||
such as `comments` and you don't want the route `api/questions/{id}/answers/{id}/comments` to be generated. You can do this by adding the parameter maxDepth in the ApiSubresource annotation or YAML/XML file configuration. | ||
Now lets add the Company class: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now lets add the Company class: | |
Now let's add the Company class: |
core/subresources.md
Outdated
} | ||
``` | ||
|
||
We did not define any Doctrine annotation here and if we want thinks to work properly with GraphQl, we need to map the `employees` field as a Link to the class `Employee` using the property `company`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did not define any Doctrine annotation here and if we want thinks to work properly with GraphQl, we need to map the `employees` field as a Link to the class `Employee` using the property `company`. | |
We did not define any Doctrine annotation here and if we want thinks to work properly with GraphQL, we need to map the `employees` field as a Link to the class `Employee` using the property `company`. |
core/subresources.md
Outdated
|
||
We did not define any Doctrine annotation here and if we want thinks to work properly with GraphQl, we need to map the `employees` field as a Link to the class `Employee` using the property `company`. | ||
|
||
As a general rule, if the property we want to crete a link from is in the `fromClass`, use `fromProperty`, if not, use `toProperty`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general rule, if the property we want to crete a link from is in the `fromClass`, use `fromProperty`, if not, use `toProperty`. | |
As a general rule, if the property we want to create a link from is in the `fromClass`, use `fromProperty`, if not, use `toProperty`. |
core/upgrade-guide.md
Outdated
@@ -0,0 +1,145 @@ | |||
# Upgrade guide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Upgrade guide | |
# Upgrade Guide |
core/upgrade-guide.md
Outdated
@@ -0,0 +1,145 @@ | |||
# Upgrade guide | |||
|
|||
## What changed between 2.6 and 2.7? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## What changed between 2.6 and 2.7? | |
## What Has Changed Between 2.6 And 2.7? |
core/upgrade-guide.md
Outdated
|
||
You can use the `api:upgrade-resource` command to upgrade your resources automatically, [see instructions here](#the-upgrade-command). | ||
|
||
### Removal of item/collection operations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Removal of item/collection operations | |
### Removal of Item/Collection Operations |
core/state-processors.md
Outdated
|
||
public function process($data, array $identifiers = [], ?string $operationName = null, array $context = []) | ||
{ | ||
$result = $this->decorated->persist($data, $context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$result = $this->decorated->persist($data, $context); | |
$result = $this->decorated->process($data, $identifiers, $operationName, $context); |
core/state-providers.md
Outdated
final class BlogPostStateProvider implements ProviderInterface | ||
{ | ||
/** | ||
* Provides data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inheritDoc?
core/state-processors.md
Outdated
$this->mailer = $mailer; | ||
} | ||
|
||
public function process($data, array $identifiers = [], ?string $operationName = null, array $context = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uriVariables?
core/state-processors.md
Outdated
return $result; | ||
} | ||
|
||
public function supports($data, array $identifiers = [], ?string $operationName = null, array $context = []): bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uriVariables?
core/state-providers.md
Outdated
services: | ||
# ... | ||
'App\DataProvider\BlogPostStateProvider': | ||
tags: [ { name: 'api_platform.state_provider', priority: 2 } ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
priority in comment since it's not the default configuration?
Co-authored-by: Alan Poulain <[email protected]>
TODO: