BookStoreSchema::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * This file is a part of GraphQL project.
4
 *
5
 * @author Alexandr Viniychuk <[email protected]>
6
 * created: 4/23/17 10:43 PM
7
 */
8
9
namespace Examples\BookStore\Schema;
10
11
12
use Examples\BookStore\DataProvider;
13
use Examples\BookStore\Schema\Field\Book\RecentBooksField;
14
use Examples\BookStore\Schema\Field\CategoriesField;
15
use Examples\BookStore\Schema\Type\AuthorType;
16
use Youshido\GraphQL\Config\Schema\SchemaConfig;
17
use Youshido\GraphQL\Schema\AbstractSchema;
18
use Youshido\GraphQL\Type\ListType\ListType;
19
20
class BookStoreSchema extends AbstractSchema
21
{
22
    public function build(SchemaConfig $config)
23
    {
24
        $config->getQuery()->addFields([
25
            'authors' => [
26
                'type'    => new ListType(new AuthorType()),
27
                'resolve' => function () {
28
                    return DataProvider::getAuthors();
29
                }
30
            ],
31
            new RecentBooksField(),
32
            new CategoriesField(),
33
        ]);
34
    }
35
36
}