protected function ThunderSchemaExtensionPluginBase::resolveBaseFields in Thunder 6.2.x
Add fields common to all entities.
Parameters
string $type: The type name.
string $entity_type_id: The entity type ID.
2 calls to ThunderSchemaExtensionPluginBase::resolveBaseFields()
- ThunderSchemaExtensionPluginBase::resolveMediaInterfaceFields in modules/
thunder_gqls/ src/ Plugin/ GraphQL/ SchemaExtension/ ThunderSchemaExtensionPluginBase.php - Add fields common to all media types.
- ThunderSchemaExtensionPluginBase::resolvePageInterfaceFields in modules/
thunder_gqls/ src/ Plugin/ GraphQL/ SchemaExtension/ ThunderSchemaExtensionPluginBase.php - Add fields common to all page types.
File
- modules/
thunder_gqls/ src/ Plugin/ GraphQL/ SchemaExtension/ ThunderSchemaExtensionPluginBase.php, line 95
Class
- ThunderSchemaExtensionPluginBase
- The base class for Thunder schema extension plugins.
Namespace
Drupal\thunder_gqls\Plugin\GraphQL\SchemaExtensionCode
protected function resolveBaseFields(string $type, string $entity_type_id) {
$this
->addFieldResolverIfNotExists($type, 'uuid', $this->builder
->produce('entity_uuid')
->map('entity', $this->builder
->fromParent()));
$this
->addFieldResolverIfNotExists($type, 'id', $this->builder
->produce('entity_id')
->map('entity', $this->builder
->fromParent()));
$this
->addFieldResolverIfNotExists($type, 'entity', $this->builder
->produce('entity_type_id')
->map('entity', $this->builder
->fromParent()));
$this
->addFieldResolverIfNotExists($type, 'name', $this->builder
->produce('entity_label')
->map('entity', $this->builder
->fromParent()));
$this
->addFieldResolverIfNotExists($type, 'language', $this->builder
->fromPath('entity', 'langcode.value'));
$entity_type = $this->entityTypeManager
->getDefinition($entity_type_id);
if ($entity_type
->hasLinkTemplate('canonical')) {
$this
->addFieldResolverIfNotExists($type, 'url', $this->builder
->compose($this->builder
->produce('entity_url')
->map('entity', $this->builder
->fromParent()), $this->builder
->produce('url_path')
->map('url', $this->builder
->fromParent())));
}
else {
$this
->addFieldResolverIfNotExists($type, 'url', $this->builder
->fromValue(NULL));
}
if (method_exists($entity_type
->getClass(), 'getCreatedTime')) {
$this
->addFieldResolverIfNotExists($type, 'created', $this->builder
->produce('entity_created')
->map('entity', $this->builder
->fromParent()));
}
if ($entity_type
->entityClassImplements(EntityChangedInterface::class)) {
$this
->addFieldResolverIfNotExists($type, 'changed', $this->builder
->produce('entity_changed')
->map('entity', $this->builder
->fromParent()));
}
if ($entity_type
->entityClassImplements(EntityPublishedInterface::class)) {
$this
->addFieldResolverIfNotExists($type, 'published', $this->builder
->produce('entity_published')
->map('entity', $this->builder
->fromParent()));
}
if ($entity_type
->entityClassImplements(EntityOwnerInterface::class)) {
$this
->addFieldResolverIfNotExists($type, 'author', $this->builder
->produce('entity_owner')
->map('entity', $this->builder
->fromParent()));
}
$this
->addFieldResolverIfNotExists($type, 'entityLinks', $this->builder
->produce('entity_links')
->map('entity', $this->builder
->fromParent()));
}