Skip to content

Commit 44d7d6d

Browse files
authored
Use description from plugin annotation also for fields and enums. (#388)
1 parent aaea896 commit 44d7d6d

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/Annotation/GraphQLAnnotationBase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ public function __construct($values) {
4242
*/
4343
public $name;
4444

45+
/**
46+
* The component description.
47+
*
48+
* @var string
49+
*/
50+
public $description = '';
51+
4552
/**
4653
* Weight for precedence calculations.
4754
*

src/Plugin/GraphQL/Enums/EnumPluginBase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Drupal\Core\Cache\CacheableDependencyInterface;
66
use Drupal\graphql\Plugin\GraphQL\PluggableSchemaManagerInterface;
77
use Drupal\graphql\Plugin\GraphQL\Traits\CacheablePluginTrait;
8+
use Drupal\graphql\Plugin\GraphQL\Traits\NamedPluginTrait;
89
use Drupal\graphql\Plugin\GraphQL\Traits\PluginTrait;
910
use Drupal\graphql\Plugin\GraphQL\TypeSystemPluginInterface;
1011
use Youshido\GraphQL\Config\Object\EnumTypeConfig;
@@ -15,6 +16,7 @@
1516
*/
1617
abstract class EnumPluginBase extends AbstractEnumType implements TypeSystemPluginInterface {
1718
use PluginTrait;
19+
use NamedPluginTrait;
1820
use CacheablePluginTrait;
1921

2022
/**
@@ -41,7 +43,8 @@ public function getValues() {
4143
*/
4244
public function buildConfig(PluggableSchemaManagerInterface $schemaManager) {
4345
$this->config = new EnumTypeConfig([
44-
'name' => $this->getPluginDefinition()['name'],
46+
'name' => $this->buildName(),
47+
'description' => $this->buildDescription(),
4548
'values' => $this->buildValues($schemaManager),
4649
]);
4750
}

src/Plugin/GraphQL/Mutations/MutationPluginBase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(array $configuration, $pluginId, $pluginDefinition)
3434
public function buildConfig(PluggableSchemaManagerInterface $schemaManager) {
3535
$this->config = new FieldConfig([
3636
'name' => $this->buildName(),
37+
'description' => $this->buildDescription(),
3738
'type' => $this->buildType($schemaManager),
3839
'args' => $this->buildArguments($schemaManager),
3940
]);

0 commit comments

Comments
 (0)