Test Failed
Push — feature-laravel-5.4 ( 6f3b9a...66d75b )
by Kirill
03:40
created

ArticlesQuery::queryArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\GraphQL\Queries;
12
13
use App\Models\Article;
14
use GraphQL\Type\Definition\Type;
15
use App\GraphQL\Types\ArticleType;
16
use Illuminate\Support\Collection;
17
use GraphQL\Type\Definition\ListOfType;
18
use App\GraphQL\Serializers\ArticleSerializer;
19
20
/**
21
 * Class ArticlesQuery.
22
 */
23
class ArticlesQuery extends AbstractQuery
24
{
25
    /**
26
     * @var array
27
     */
28
    protected $attributes = [
29
        'name'        => 'Article list query',
30
        'description' => 'Returns a list of available articles',
31
    ];
32
33
    /**
34
     * @return ListOfType
35
     */
36
    public function type(): ListOfType
37
    {
38
        return Type::listOf(\GraphQL::type(ArticleType::getName()));
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    protected function queryArguments(): array
45
    {
46
        return [
47
            'id'     => [
48
                'type'        => Type::id(),
49
                'description' => 'Article identifier',
50
            ],
51
        ];
52
    }
53
54
    /**
55
     * @param $root
56
     * @param  array      $args
57
     * @return Collection
58
     */
59
    public function resolve($root, array $args = []): Collection
0 ignored issues
show
Unused Code introduced by
The parameter $root 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...
60
    {
61
        $query = $this->queryFor(Article::class, $args)
62
            ->latestPublished();
63
64
        return ArticleSerializer::collection($query->get());
65
    }
66
}
67