EntityCreated.php in GraphQL 8.3
File
modules/graphql_core/src/Plugin/GraphQL/Fields/Entity/EntityCreated.php
View source
<?php
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Entity;
use Drupal\graphql\GraphQL\Execution\ResolveContext;
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
use GraphQL\Type\Definition\ResolveInfo;
use DateTime;
class EntityCreated extends FieldPluginBase {
protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
if (method_exists($value, 'getCreatedTime')) {
$datetime = new DateTime();
$datetime
->setTimestamp($value
->getCreatedTime());
$format = isset($args['format']) ? $args['format'] : DateTime::ISO8601;
(yield $datetime
->format($format));
}
}
}
Classes
Name |
Description |
EntityCreated |
TODO: Should we derive this for each entity type individually? |