diff --git a/src/GraphQL/DataObjectType/PimcoreObjectType.php b/src/GraphQL/DataObjectType/PimcoreObjectType.php index b266676c..1cb4524b 100644 --- a/src/GraphQL/DataObjectType/PimcoreObjectType.php +++ b/src/GraphQL/DataObjectType/PimcoreObjectType.php @@ -81,6 +81,21 @@ public function build($context = []) 'id' => Type::id(), 'creationDate' => Type::int(), 'modificationDate' => Type::int(), + 'version' => [ + 'type' => Type::int(), + 'resolve' => function ($value = null, $args = [], $context = [], ResolveInfo $resolveInfo = null) { + $object = \Pimcore\Model\DataObject::getById($value['id']); + if ($object) { + foreach (array_reverse($object->getVersions()) as $version) { + if ($object->getModificationDate() === $version->getDate()) { + return $version->getId(); + } + } + } + + return null; + } + ], 'objectType' => [ 'type' => Type::string(), 'resolve' => function ($value = null, $args = [], $context = [], ResolveInfo $resolveInfo = null) {