Skip to content

Commit e7a9780

Browse files
committed
fix enum formt
1 parent 23a286e commit e7a9780

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogGraphQl\Model\Resolver\Product;
9+
10+
use Magento\Framework\GraphQl\Config\Element\Field;
11+
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
12+
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
14+
15+
/**
16+
* Format the option type value.
17+
*/
18+
class CustomizableDateTypeOptionValue implements ResolverInterface
19+
{
20+
/**
21+
* Resolver option code.
22+
*/
23+
private const OPTION_CODE = 'type';
24+
25+
/**
26+
* Resolver enum type options to up case format.
27+
*
28+
* @param Field $field
29+
* @param ContextInterface $context
30+
* @param ResolveInfo $info
31+
* @param array|null $value
32+
* @param array|null $args
33+
*
34+
* @return string
35+
*/
36+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null): string
37+
{
38+
$dteType = $value[self::OPTION_CODE] ?? '';
39+
40+
return strtoupper($dteType);
41+
}
42+
}

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ enum PriceTypeEnum @doc(description: "This enumeration the price type.") {
5050
}
5151

5252
enum CustomizableDateTypeEnum @doc(description: "This enumeration customizable date type.") {
53-
date
54-
date_time
55-
time
53+
DATE
54+
DATE_TIME
55+
TIME
5656
}
5757

5858
type ProductPrices @doc(description: "ProductPrices is deprecated, replaced by PriceRange. The ProductPrices object contains the regular price of an item, as well as its minimum and maximum prices. Only composite products, which include bundle, configurable, and grouped products, can contain a minimum and maximum price.") {
@@ -159,7 +159,7 @@ type CustomizableDateOption implements CustomizableOptionInterface @doc(descript
159159
type CustomizableDateValue @doc(description: "CustomizableDateValue defines the price and sku of a product whose page contains a customized date picker.") {
160160
price: Float @doc(description: "The price assigned to this option.")
161161
price_type: PriceTypeEnum @doc(description: "FIXED, PERCENT, or DYNAMIC.")
162-
type: CustomizableDateTypeEnum @doc(description: "date, date_time or time")
162+
type: CustomizableDateTypeEnum @doc(description: "DATE, DATE_TIME or TIME") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CustomizableDateTypeOptionValue")
163163
sku: String @doc(description: "The Stock Keeping Unit for this option.")
164164
uid: ID! @doc(description: "A string that encodes option details.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CustomizableEnteredOptionValueUid") # A Base64 string that encodes option details.
165165
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/Options/CustomizableOptionsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,19 @@ public function getProductCustomizableOptionsProvider(): array
111111
[
112112
'title' => 'date option',
113113
'values' => [
114-
'type' => 'date'
114+
'type' => 'DATE'
115115
]
116116
],
117117
[
118118
'title' => 'date_time option',
119119
'values' => [
120-
'type' => 'date_time'
120+
'type' => 'DATE_TIME'
121121
]
122122
],
123123
[
124124
'title' => 'time option',
125125
'values' => [
126-
'type' => 'time'
126+
'type' => 'TIME'
127127
]
128128
]
129129
]

0 commit comments

Comments
 (0)