1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Drupal\graphql\GraphQL\Type; |
4
|
|
|
|
5
|
|
|
use Drupal\graphql\GraphQL\CacheableEdgeInterface; |
6
|
|
|
use Drupal\graphql\GraphQL\CacheableEdgeTrait; |
7
|
|
|
use Drupal\graphql\Plugin\GraphQL\Types\TypePluginBase; |
8
|
|
|
use Drupal\graphql\Plugin\GraphQL\TypeSystemPluginReferenceInterface; |
9
|
|
|
use Drupal\graphql\Plugin\GraphQL\TypeSystemPluginReferenceTrait; |
10
|
|
|
use Youshido\GraphQL\Config\Object\ObjectTypeConfig; |
11
|
|
|
use Youshido\GraphQL\Execution\ResolveInfo; |
12
|
|
|
use Youshido\GraphQL\Type\Object\AbstractObjectType; |
13
|
|
|
|
14
|
|
|
class ObjectType extends AbstractObjectType implements TypeSystemPluginReferenceInterface, CacheableEdgeInterface { |
15
|
|
|
use TypeSystemPluginReferenceTrait; |
16
|
|
|
use CacheableEdgeTrait; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
|
|
public function __construct(TypePluginBase $plugin, array $config = []) { |
22
|
|
|
$this->plugin = $plugin; |
23
|
|
|
$this->config = new ObjectTypeConfig($config, $this, TRUE); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
public function getName() { |
30
|
|
|
return $this->getConfigValue('name'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Checks whether this type applies to a given object. |
35
|
|
|
* |
36
|
|
|
* @param mixed $object |
37
|
|
|
* The object to check against. |
38
|
|
|
* @param \Youshido\GraphQL\Execution\ResolveInfo|null $info |
39
|
|
|
* The resolve info object. |
40
|
|
|
* |
41
|
|
|
* @return bool |
42
|
|
|
* TRUE if this type applies to the given object, FALSE otherwise. |
43
|
|
|
*/ |
44
|
|
|
public function applies($object, ResolveInfo $info = NULL) { |
45
|
|
|
if (($plugin = $this->getPluginFromResolveInfo($info)) && $plugin instanceof TypePluginBase) { |
|
|
|
|
46
|
|
|
return $plugin->applies($object); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return FALSE; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
|
|
public function build($config) { |
56
|
|
|
// Nothing to do here. |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):