Skip to content

Commit 6d814cc

Browse files
authored
LYNX-686 Customer query returns Internal Server Error if value for deleted custom attribute exists for a customer
1 parent 753e8d3 commit 6d814cc

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

app/code/Magento/EavGraphQl/Model/TypeResolver/AttributeValue.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\EavGraphQl\Model\TypeResolver;
99

1010
use Magento\Eav\Model\Attribute;
1111
use Magento\Eav\Model\AttributeRepository;
12+
use Magento\Framework\Exception\NoSuchEntityException;
1213
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
14+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1315

1416
/**
1517
* @inheritdoc
@@ -42,14 +44,20 @@ public function __construct(
4244

4345
/**
4446
* @inheritdoc
47+
*
48+
* @throws GraphQlNoSuchEntityException
4549
*/
4650
public function resolveType(array $data): string
4751
{
48-
/** @var Attribute $attr */
49-
$attr = $this->attributeRepository->get(
50-
$data['entity_type'],
51-
$data['code'],
52-
);
52+
try {
53+
/** @var Attribute $attr */
54+
$attr = $this->attributeRepository->get(
55+
$data['entity_type'],
56+
$data['code'],
57+
);
58+
} catch (NoSuchEntityException $e) {
59+
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
60+
}
5361

5462
if (in_array($attr->getFrontendInput(), $this->frontendInputs)) {
5563
return 'AttributeSelectedOptions';

0 commit comments

Comments
 (0)