| @@ 22-60 (lines=39) @@ | ||
| 19 | /** |
|
| 20 | * Resolve queries |
|
| 21 | */ |
|
| 22 | class MutationAddAnnotationParser extends MutationAnnotationParser |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | public function supports($annotation): bool |
|
| 28 | { |
|
| 29 | return $annotation instanceof Annotation\MutationAdd; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * {@inheritdoc} |
|
| 34 | */ |
|
| 35 | public function parse($annotation, \ReflectionClass $refClass, DefinitionManager $definitionManager) |
|
| 36 | { |
|
| 37 | if (!$annotation->name) { |
|
| 38 | $annotation->name = 'add'.ucfirst($this->getDefaultName($refClass, $definitionManager)); |
|
| 39 | } |
|
| 40 | ||
| 41 | parent::parse($annotation, $refClass, $definitionManager); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * {@inheritdoc} |
|
| 46 | */ |
|
| 47 | public function createMutation(Annotation\Mutation $annotation): MutationDefinition |
|
| 48 | { |
|
| 49 | $mutation = parent::createMutation($annotation); |
|
| 50 | if (!$annotation->resolver) { |
|
| 51 | $mutation->setResolver(AddNodeMutation::class); |
|
| 52 | } |
|
| 53 | ||
| 54 | if (!$annotation->payload) { |
|
| 55 | $mutation->setType(AddNodePayload::class); |
|
| 56 | } |
|
| 57 | ||
| 58 | return $mutation; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 22-60 (lines=39) @@ | ||
| 19 | /** |
|
| 20 | * Resolve queries |
|
| 21 | */ |
|
| 22 | class MutationUpdateAnnotationParser extends MutationAnnotationParser |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | public function supports($annotation): bool |
|
| 28 | { |
|
| 29 | return $annotation instanceof Annotation\MutationUpdate; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * {@inheritdoc} |
|
| 34 | */ |
|
| 35 | public function parse($annotation, \ReflectionClass $refClass, DefinitionManager $definitionManager) |
|
| 36 | { |
|
| 37 | if (!$annotation->name) { |
|
| 38 | $annotation->name = 'update'.ucfirst($this->getDefaultName($refClass, $definitionManager)); |
|
| 39 | } |
|
| 40 | ||
| 41 | parent::parse($annotation, $refClass, $definitionManager); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * {@inheritdoc} |
|
| 46 | */ |
|
| 47 | public function createMutation(Annotation\Mutation $annotation): MutationDefinition |
|
| 48 | { |
|
| 49 | $mutation = parent::createMutation($annotation); |
|
| 50 | if (!$annotation->resolver) { |
|
| 51 | $mutation->setResolver(UpdateNodeMutation::class); |
|
| 52 | } |
|
| 53 | ||
| 54 | if (!$annotation->payload) { |
|
| 55 | $mutation->setType(UpdateNodePayload::class); |
|
| 56 | } |
|
| 57 | ||
| 58 | return $mutation; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||