Skip to content

Commit 0ebc884

Browse files
blazeyofubhy
authored andcommitted
#389 Fix for interface regression introduced by base fields. (#390)
1 parent 0a24da8 commit 0ebc884

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

modules/graphql_core/src/Plugin/Deriver/Fields/EntityFieldDeriverBase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,17 @@ public function getDerivativeDefinitions($basePluginDefinition) {
139139
return $this->derivatives;
140140
}
141141

142+
/**
143+
* Tells if given field has just a single property.
144+
*
145+
* @param \Drupal\Core\Field\FieldStorageDefinitionInterface $definition
146+
* Field definition.
147+
*
148+
* @return bool
149+
*/
150+
protected function isSinglePropertyField(FieldStorageDefinitionInterface $definition) {
151+
$properties = $definition->getPropertyDefinitions();
152+
return count($properties) === 1;
153+
}
154+
142155
}

modules/graphql_core/src/Plugin/Deriver/Types/EntityFieldTypeDeriver.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ class EntityFieldTypeDeriver extends EntityFieldDeriverBase {
2020
protected function getBaseFieldDefinition($entityTypeId, BaseFieldDefinition $baseFieldDefinition, array $basePluginDefinition) {
2121
$fieldName = $baseFieldDefinition->getName();
2222

23+
if ($this->isSinglePropertyField($baseFieldDefinition)) {
24+
return;
25+
}
26+
2327
$this->derivatives["$entityTypeId-$fieldName"] = [
2428
'name' => EntityFieldType::getId($entityTypeId, $fieldName),
2529
'entity_type' => $entityTypeId,
2630
'data_type' => "entity:$entityTypeId:$fieldName",
27-
'interfaces' => [EntityType::getId($entityTypeId)],
2831
] + $basePluginDefinition;
2932
}
3033

@@ -34,11 +37,14 @@ protected function getBaseFieldDefinition($entityTypeId, BaseFieldDefinition $ba
3437
protected function getConfigFieldDefinition($entityTypeId, $bundleId, FieldStorageDefinitionInterface $storage, array $basePluginDefinition) {
3538
$fieldName = $storage->getName();
3639

40+
if ($this->isSinglePropertyField($storage)) {
41+
return;
42+
}
43+
3744
$this->derivatives["$entityTypeId-$bundleId-$fieldName"] = [
3845
'name' => EntityFieldType::getId($entityTypeId, $fieldName),
3946
'entity_type' => $entityTypeId,
4047
'data_type' => "entity:$entityTypeId:$bundleId:$fieldName",
41-
'interfaces' => [EntityBundle::getId($entityTypeId, $bundleId)],
4248
'bundle' => $bundleId,
4349
] + $basePluginDefinition;
4450
}

modules/graphql_core/tests/src/Kernel/Entity/EntityFieldValueTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Drupal\Tests\graphql_core\Kernel\Entity;
44

55
use Drupal\Component\Utility\NestedArray;
6-
use Drupal\Core\Entity\Entity\EntityViewMode;
76
use Drupal\field\Entity\FieldConfig;
87
use Drupal\field\Entity\FieldStorageConfig;
98
use Drupal\file\Entity\File;

0 commit comments

Comments
 (0)