ImageHeight.php in GraphQL 8.3
File
modules/graphql_core/src/Plugin/GraphQL/Fields/Entity/Fields/Image/ImageHeight.phpView source
<?php
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Entity\Fields\Image;
use Drupal\graphql\GraphQL\Execution\ResolveContext;
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
use Drupal\image\Plugin\Field\FieldType\ImageItem;
use GraphQL\Type\Definition\ResolveInfo;
/**
* Retrieve the image height.
*
* @GraphQLField(
* id = "image_height",
* secure = true,
* name = "height",
* type = "Int",
* provider = "image",
* field_types = {"image"},
* deriver = "Drupal\graphql_core\Plugin\Deriver\Fields\EntityFieldPropertyDeriver"
* )
*/
class ImageHeight extends FieldPluginBase {
/**
* {@inheritdoc}
*/
protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
if ($value instanceof ImageItem && $value->entity && $value->entity
->access('view')) {
(yield (int) $value->height);
}
}
}
Classes
Name | Description |
---|---|
ImageHeight | Retrieve the image height. |