Skip to content

Commit 20dc211

Browse files
authored
Update state-processors.md
State processor clarification for graphql operations.
1 parent 22340ba commit 20dc211

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/state-processors.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ class BlogPost {}
139139
### Symfony State Processor mechanism
140140
If you want to execute custom business logic before or after persistence, this can be achieved by using [composition](https://en.wikipedia.org/wiki/Object_composition).
141141

142+
For GraphQL a remove Operation type will not be `DeleteOperationInterface` type but `ApiPlatform\Metadata\GraphQl\Mutation` with a `getName()` result of "delete". You can insert this to use the `$removeProcessor`:
143+
144+
```
145+
if ($operation instanceof \ApiPlatform\Metadata\GraphQl\Mutation && $operation->getName() === 'delete') {
146+
return $this->removeProcessor->process($data, $operation, $uriVariables, $context);
147+
}
148+
```
149+
142150
Here is an implementation example which uses [Symfony Mailer](https://symfony.com/doc/current/mailer.html) to send new users a welcome email after a REST `POST` or GraphQL `create` operation, in a project using the native Doctrine ORM state processor:
143151

144152
```php

0 commit comments

Comments
 (0)