Skip to content

Commit 9077f31

Browse files
committed
LYNX-100: Fix WebAPI tests
1 parent ec8b705 commit 9077f31

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

app/code/Magento/EavGraphQl/Model/Output/GetAttributeData.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
7+
68
declare(strict_types=1);
79

810
namespace Magento\EavGraphQl\Model\Output;
@@ -76,7 +78,7 @@ public function execute(
7678
'is_required' => $attribute->getIsRequired(),
7779
'default_value' => $attribute->getDefaultValue(),
7880
'is_unique' => $attribute->getIsUnique(),
79-
// 'options' => $this->getOptions($attribute),
81+
'options' => $this->getOptions($attribute),
8082
'attribute' => $attribute
8183
];
8284
}
@@ -95,7 +97,7 @@ private function getOptions(AttributeInterface $attribute): array
9597
return array_filter(
9698
array_map(
9799
function (AttributeOptionInterface $option) use ($attribute) {
98-
$value = (string)$option->getValue();
100+
$value = is_array($option->getValue()) ? (empty($option->getValue()) ? '' : (string)$option->getValue()[0]['value']) : (string)$option->getValue();
99101
$label = (string)$option->getLabel();
100102
if (empty(trim($value)) && empty(trim($label))) {
101103
return null;

app/code/Magento/EavGraphQl/Model/Resolver/AttributesList.php

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
use Magento\Framework\GraphQl\Query\ResolverInterface;
1616
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1717
use Magento\EavGraphQl\Model\Output\GetAttributeData;
18-
use Magento\Framework\GraphQl\Query\Uid;
19-
use Magento\EavGraphQl\Model\Uid as AttributeUid;
18+
use Magento\EavGraphQl\Model\Output\GetAttributeDataInterface;
2019

2120
/**
2221
* Resolve attribute options data for custom attribute.
@@ -29,19 +28,9 @@ class AttributesList implements ResolverInterface
2928
private AttributeRepository $attributeRepository;
3029

3130
/**
32-
* @var Uid
31+
* @var GetAttributeDataInterface
3332
*/
34-
private Uid $uid;
35-
36-
/**
37-
* @var AttributeUid
38-
*/
39-
private AttributeUid $attributeUid;
40-
41-
/**
42-
* @var GetAttributeData
43-
*/
44-
private GetAttributeData $getAttributeData;
33+
private GetAttributeDataInterface $getAttributeData;
4534

4635
/**
4736
* @var SearchCriteriaBuilder
@@ -62,25 +51,21 @@ class AttributesList implements ResolverInterface
6251
* @param AttributeRepository $attributeRepository
6352
* @param SearchCriteriaBuilder $searchCriteriaBuilder
6453
* @param EnumLookup $enumLookup
65-
* @param Uid $uid
66-
* @param AttributeUid $attributeUid
54+
* @param GetAttributeDataInterface $getAttributeData
6755
* @param array $resolvers
6856
*/
6957
public function __construct(
7058
AttributeRepository $attributeRepository,
7159
SearchCriteriaBuilder $searchCriteriaBuilder,
7260
EnumLookup $enumLookup,
73-
Uid $uid,
74-
AttributeUid $attributeUid,
61+
GetAttributeDataInterface $getAttributeData,
7562
array $resolvers = []
7663
) {
7764
$this->attributeRepository = $attributeRepository;
7865
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
7966
$this->enumLookup = $enumLookup;
80-
$this->uid = $uid;
81-
$this->attributeUid = $attributeUid;
67+
$this->getAttributeData = $getAttributeData;
8268
$this->resolvers = $resolvers;
83-
$this->getAttributeData = new GetAttributeData($this->attributeUid, $this->uid, $this->enumLookup);
8469
}
8570

8671
/**

0 commit comments

Comments
 (0)