|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\graphql_core\Plugin\GraphQL\Fields; |
|
4
|
|
|
|
|
5
|
|
|
use Drupal\Component\Render\MarkupInterface; |
|
|
|
|
|
|
6
|
|
|
use Drupal\Core\Cache\CacheableDependencyInterface; |
|
|
|
|
|
|
7
|
|
|
use Drupal\Core\Entity\ContentEntityInterface; |
|
|
|
|
|
|
8
|
|
|
use Drupal\Core\Field\FieldItemInterface; |
|
|
|
|
|
|
9
|
|
|
use Drupal\graphql\GraphQL\Execution\ResolveContext; |
|
10
|
|
|
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase; |
|
11
|
|
|
use GraphQL\Type\Definition\ResolveInfo; |
|
12
|
|
|
use GraphQL\Type\Definition\ScalarType; |
|
13
|
|
|
use GraphQL\Type\Definition\WrappingType; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Base class for entity field plugins. |
|
17
|
|
|
*/ |
|
18
|
|
|
class EntityFieldBase extends FieldPluginBase { |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* {@inheritdoc} |
|
22
|
|
|
*/ |
|
23
|
|
|
protected function resolveItem($item, array $args, ResolveContext $context, ResolveInfo $info) { |
|
24
|
|
|
if ($item instanceof FieldItemInterface) { |
|
25
|
|
|
$definition = $this->getPluginDefinition(); |
|
26
|
|
|
$property = $definition['property']; |
|
27
|
|
|
$itemProperty = $item->get($property); |
|
28
|
|
|
$result = $itemProperty->getValue(); |
|
29
|
|
|
$result = $result instanceof MarkupInterface ? $result->__toString() : $result; |
|
30
|
|
|
|
|
31
|
|
|
$type = $info->returnType; |
|
32
|
|
|
$type = $type instanceof WrappingType ? $type->getWrappedType(TRUE) : $type; |
|
33
|
|
|
if ($type instanceof ScalarType) { |
|
34
|
|
|
$result = is_null($result) ? NULL : $type->serialize($result); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
if ($result instanceof ContentEntityInterface && $result->isTranslatable() && $language = $context->getContext('language', $info)) { |
|
38
|
|
|
if ($result->hasTranslation($language)) { |
|
39
|
|
|
$result = $result->getTranslation($language); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
// if ($itemProperty instanceof CacheableDependencyInterface) { |
|
44
|
|
|
// $context->addCacheTags($itemProperty->getCacheTags()); |
|
45
|
|
|
// $context->addCacheContexts($itemProperty->getCacheContexts()); |
|
46
|
|
|
// $context->mergeCacheMaxAge($itemProperty->getCacheMaxAge()); |
|
47
|
|
|
// } |
|
48
|
|
|
|
|
49
|
|
|
return $result; |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths