1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Explicit Architecture POC, |
7
|
|
|
* which is created on top of the Symfony Demo application. |
8
|
|
|
* |
9
|
|
|
* (c) Herberto Graça <[email protected]> |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please view the LICENSE |
12
|
|
|
* file that was distributed with this source code. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Acme\App\Presentation\Api\GraphQl\Node\Post; |
16
|
|
|
|
17
|
|
|
use Acme\App\Core\Component\Blog\Domain\Post\PostId; |
18
|
|
|
use Acme\App\Presentation\Api\GraphQl\Node\Post\Connection\Author\PostAuthorsResolver; |
19
|
|
|
use Acme\App\Presentation\Api\GraphQl\Node\Post\Connection\Comment\PostCommentsResolver; |
20
|
|
|
use Acme\App\Presentation\Api\GraphQl\Node\Post\Connection\Tag\PostTagsResolver; |
21
|
|
|
use ArrayObject; |
22
|
|
|
use GraphQL\Type\Definition\ResolveInfo; |
23
|
|
|
use Overblog\GraphQLBundle\Definition\Argument; |
24
|
|
|
use Overblog\GraphQLBundle\Resolver\ResolverMap as BaseResolverMap; |
25
|
|
|
|
26
|
|
|
final class PostResolverMap extends BaseResolverMap |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var PostCommentsResolver |
30
|
|
|
*/ |
31
|
|
|
private $postCommentsResolver; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var PostTagsResolver |
35
|
|
|
*/ |
36
|
|
|
private $postTagsResolver; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var PostAuthorsResolver |
40
|
|
|
*/ |
41
|
|
|
private $postAuthorsResolver; |
42
|
|
|
|
43
|
|
|
public function __construct( |
44
|
|
|
PostCommentsResolver $postCommentsResolver, |
45
|
|
|
PostTagsResolver $postTagsResolver, |
46
|
|
|
PostAuthorsResolver $postAuthorsResolver |
47
|
|
|
) { |
48
|
|
|
$this->postCommentsResolver = $postCommentsResolver; |
49
|
|
|
$this->postTagsResolver = $postTagsResolver; |
50
|
|
|
$this->postAuthorsResolver = $postAuthorsResolver; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
protected function map(): array |
54
|
|
|
{ |
55
|
|
|
return [ |
56
|
|
|
'Post' => [ |
57
|
|
|
'comments' => function (PostViewModel $value, Argument $args, ArrayObject $context, ResolveInfo $info) { |
|
|
|
|
58
|
|
|
return $this->postCommentsResolver->getPostCommentsConnection(new PostId($value->getId())); |
59
|
|
|
}, |
60
|
|
|
'tags' => function (PostViewModel $value, Argument $args, ArrayObject $context, ResolveInfo $info) { |
|
|
|
|
61
|
|
|
return $this->postTagsResolver->getPostTagsConnection(new PostId($value->getId())); |
62
|
|
|
}, |
63
|
|
|
'authors' => function (PostViewModel $value, Argument $args, ArrayObject $context, ResolveInfo $info) { |
|
|
|
|
64
|
|
|
return $this->postAuthorsResolver->getPostAuthorsConnection(new PostId($value->getId())); |
65
|
|
|
}, |
66
|
|
|
], |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.