|
1
|
|
|
<?php |
|
2
|
|
|
/******************************************************************************* |
|
3
|
|
|
* This file is part of the GraphQL Bundle package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) YnloUltratech <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
******************************************************************************/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Ynlo\GraphQLBundle\Type\Definition; |
|
12
|
|
|
|
|
13
|
|
|
use GraphQL\Type\Definition\InterfaceType; |
|
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
|
16
|
|
|
use Ynlo\GraphQLBundle\Definition\InterfaceDefinition; |
|
17
|
|
|
use Ynlo\GraphQLBundle\Util\GraphQLBuilder; |
|
18
|
|
|
use Ynlo\GraphQLBundle\Util\TypeUtil; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class InterfaceDefinitionType |
|
22
|
|
|
*/ |
|
23
|
|
|
class InterfaceDefinitionType extends InterfaceType implements EndpointAwareInterface, ContainerAwareInterface |
|
24
|
|
|
{ |
|
25
|
|
|
use ContainerAwareTrait; |
|
26
|
|
|
use EndpointAwareTrait; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var InterfaceDefinition |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $definition; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* InterfaceDefinitionType constructor. |
|
35
|
|
|
* |
|
36
|
|
|
* @param InterfaceDefinition $definition |
|
37
|
|
|
*/ |
|
38
|
|
|
public function __construct(InterfaceDefinition $definition) |
|
39
|
22 |
|
{ |
|
40
|
|
|
$this->definition = $definition; |
|
41
|
22 |
|
|
|
42
|
|
|
parent::__construct( |
|
43
|
22 |
|
[ |
|
44
|
|
|
'name' => $definition->getName(), |
|
45
|
22 |
|
'description' => $definition->getDescription(), |
|
46
|
22 |
|
'fields' => function () use ($definition) { |
|
47
|
22 |
|
return GraphQLBuilder::resolveFields($definition); |
|
48
|
22 |
|
}, |
|
49
|
22 |
|
'resolveType' => function ($value) { |
|
50
|
22 |
|
return TypeUtil::resolveObjectType($this->endpoint, $value); |
|
51
|
7 |
|
}, |
|
52
|
7 |
|
] |
|
53
|
|
|
); |
|
54
|
7 |
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|