Completed
Pull Request — master (#204)
by Ryan
11:34
created

LikePostField   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 6
dl 0
loc 26
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * LikePost.php
4
 */
5
6
namespace Examples\Blog\Schema;
7
8
9
use Youshido\GraphQL\Config\Field\FieldConfig;
10
use Youshido\GraphQL\Execution\ResolveInfo;
11
use Youshido\GraphQL\Field\AbstractField;
12
use Youshido\GraphQL\Type\NonNullType;
13
use Youshido\GraphQL\Type\Scalar\IntType;
14
15
class LikePostField extends AbstractField
16
{
17
18
    /**
19
     * @param null        $value
20
     * @param array       $args
21
     * @param ResolveInfo $info
22
     * @return mixed
23
     */
24
    public function resolve($value, array $args, ResolveInfo $info)
25
    {
26
        return $info->getReturnType()->getOne($args['id']);
27
    }
28
29
    public function getType()
30
    {
31
        return new PostType();
32
    }
33
34
    public function build(FieldConfig $config)
35
    {
36
        $config->addArgument('id', new NonNullType(new IntType()));
37
    }
38
39
40
}
41