Completed
Push — master ( f8702a...461e07 )
by Alexandr
04:08
created

BlogSchema   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 12

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 12
dl 0
loc 41
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B build() 0 37 1
1
<?php
2
/**
3
 * BlogSchema.php
4
 */
5
6
namespace Examples\Blog\Schema;
7
8
use Youshido\GraphQL\AbstractSchema;
9
use Youshido\GraphQL\Type\Config\Schema\SchemaConfig;
10
use Youshido\GraphQL\Type\ListType\ListType;
11
use Youshido\GraphQL\Type\Scalar\StringType;
12
13
class BlogSchema extends AbstractSchema
14
{
15
    public function build(SchemaConfig $config)
16
    {
17
        $config->getQuery()->addFields([
18
            'latestPost'           => new PostType(),
19
            'randomBanner'         => [
20
                'type'    => new BannerType(),
21
                'resolve' => function () {
22
                    return DataProvider::getBanner(rand(1, 10));
23
                }
24
            ],
25
            'pageContentUnion'     => [
26
                'type'    => new ListType(new ContentBlockUnion()),
27
                'resolve' => function () {
28
                    return [DataProvider::getPost(1), DataProvider::getBanner(1)];
29
                }
30
            ],
31
            'pageContentInterface' => [
32
                'type'    => new ListType(new ContentBlockInterface()),
33
                'resolve' => function () {
34
                    return [DataProvider::getPost(2), DataProvider::getBanner(3)];
35
                }
36
            ]
37
        ]);
38
        $config->getMutation()->addFields([
39
            'likePost'   => new LikePost(),
40
            'createPost' => [
41
                'type'   => new PostType(),
42
                'args' => [
43
                    'post'   => new PostInputType(),
44
                    'author' => new StringType()
45
                ],
46
                'resolve' => function($value, $args, $type) {
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
                    return DataProvider::getPost(10);
48
                }
49
            ]
50
        ]);
51
    }
52
53
}
54