diff --git a/src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyObjectRelation.php b/src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyObjectRelation.php index accf7abc..b64091e4 100644 --- a/src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyObjectRelation.php +++ b/src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyObjectRelation.php @@ -21,6 +21,7 @@ use Pimcore\Model\DataObject\Concrete; use Pimcore\Model\DataObject\Data\ObjectMetadata; use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData; +use Pimcore\Model\Exception\NotFoundException; class AdvancedManyToManyObjectRelation extends Base { @@ -58,6 +59,13 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info) $item->setData($data); } $result[] = $item; + } else { + throw new NotFoundException( + sprintf('Element with id %s or fullpath %s not found', + $newValueItemValue['id'], + $newValueItemValue['fullpath'] + ) + ); } } } diff --git a/src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyRelation.php b/src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyRelation.php index fbc35d28..ee0752ea 100644 --- a/src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyRelation.php +++ b/src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyRelation.php @@ -21,6 +21,7 @@ use Pimcore\Model\DataObject\Concrete; use Pimcore\Model\DataObject\Data\ElementMetadata; use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData; +use Pimcore\Model\Exception\NotFoundException; class AdvancedManyToManyRelation extends Base { @@ -57,6 +58,13 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info) $item->setData($data); } $result[] = $item; + } else { + throw new NotFoundException( + sprintf('Element with id %s or fullpath %s not found', + $newValueItemValue['id'], + $newValueItemValue['fullpath'] + ) + ); } } } diff --git a/src/GraphQL/DataObjectInputProcessor/ManyToManyObjectRelation.php b/src/GraphQL/DataObjectInputProcessor/ManyToManyObjectRelation.php index 3d3b3dc6..a441bda6 100644 --- a/src/GraphQL/DataObjectInputProcessor/ManyToManyObjectRelation.php +++ b/src/GraphQL/DataObjectInputProcessor/ManyToManyObjectRelation.php @@ -21,6 +21,7 @@ use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ElementIdentificationTrait; use Pimcore\Model\DataObject\Concrete; use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData; +use Pimcore\Model\Exception\NotFoundException; class ManyToManyObjectRelation extends Base { @@ -50,6 +51,13 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info) if ($element) { $result[] = $element; + } else { + throw new NotFoundException( + sprintf('Element with id %s or fullpath %s not found', + $newValueItemValue['id'], + $newValueItemValue['fullpath'] + ) + ); } } } diff --git a/src/GraphQL/DataObjectInputProcessor/ManyToManyRelation.php b/src/GraphQL/DataObjectInputProcessor/ManyToManyRelation.php index 2826ba76..0f5e39f6 100644 --- a/src/GraphQL/DataObjectInputProcessor/ManyToManyRelation.php +++ b/src/GraphQL/DataObjectInputProcessor/ManyToManyRelation.php @@ -20,6 +20,7 @@ use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ElementIdentificationTrait; use Pimcore\Model\DataObject\Concrete; use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData; +use Pimcore\Model\Exception\NotFoundException; class ManyToManyRelation extends Base { @@ -45,6 +46,13 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info) if ($element) { $result[] = $element; + } else { + throw new NotFoundException( + sprintf('Element with id %s or fullpath %s not found', + $newValueItemValue['id'], + $newValueItemValue['fullpath'] + ) + ); } } } diff --git a/src/GraphQL/DataObjectInputProcessor/ManyToOneRelation.php b/src/GraphQL/DataObjectInputProcessor/ManyToOneRelation.php index a722cdbb..aba68702 100644 --- a/src/GraphQL/DataObjectInputProcessor/ManyToOneRelation.php +++ b/src/GraphQL/DataObjectInputProcessor/ManyToOneRelation.php @@ -20,6 +20,7 @@ use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ElementIdentificationTrait; use Pimcore\Model\DataObject\Concrete; use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData; +use Pimcore\Model\Exception\NotFoundException; class ManyToOneRelation extends Base { @@ -40,8 +41,18 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info): $me = $this; Service::setValue($object, $attribute, function ($container, $setter) use ($newValue) { $element = null; + if (is_array($newValue)) { $element = $this->getElementByTypeAndIdOrPath($newValue); + + if (!$element) { + throw new NotFoundException( + sprintf('Element with id %s or fullpath %s not found', + $newValue['id'], + $newValue['fullpath'] + ) + ); + } } return $container->$setter($element); diff --git a/src/GraphQL/Resolver/QueryType.php b/src/GraphQL/Resolver/QueryType.php index 03df56a8..9fa330ad 100644 --- a/src/GraphQL/Resolver/QueryType.php +++ b/src/GraphQL/Resolver/QueryType.php @@ -444,10 +444,10 @@ static function ($fullpath) use ($db) { return $db->quote($tag); }, $args['tags']))); - $conditionParts[] = "o_id IN ( + $conditionParts[] = sprintf("%s IN ( SELECT cId FROM tags_assignment INNER JOIN tags ON tags.id = tags_assignment.tagid WHERE - ctype = 'object' AND LOWER(tags.name) IN (" . $tags . '))'; + ctype = 'object' AND LOWER(tags.name) IN (", Service::getVersionDependentDatabaseColumnName('o_id')) . $tags . '))'; } // paging