Skip to content

Commit 330e763

Browse files
author
Prabhu Ram
committed
- Removed dependency between QuoteGQL and WishlistGQL (magento/architecture#413)
- fixed uid field types (magento/architecture#412) - fixed api functional tests
1 parent ec99fef commit 330e763

File tree

16 files changed

+53
-48
lines changed

16 files changed

+53
-48
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,8 @@ enum CurrencyEnum @doc(description: "The list of available currency codes") {
277277
TRL
278278
XPF
279279
}
280+
281+
input EnteredOptionInput @doc(description: "Defines a customer-entered option") {
282+
uid: ID! @doc(description: "An encoded ID")
283+
value: String! @doc(description: "Text the customer entered")
284+
}

app/code/Magento/Quote/Model/Cart/BuyRequest/CustomizableOptionDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function execute(CartItem $cartItem): array
4343

4444
foreach ($cartItem->getEnteredOptions() as $option) {
4545
// phpcs:ignore Magento2.Functions.DiscouragedFunction
46-
$optionData = \explode('/', base64_decode($option->getId()));
46+
$optionData = \explode('/', base64_decode($option->getUid()));
4747

4848
if ($this->isProviderApplicable($optionData) === false) {
4949
continue;

app/code/Magento/Quote/Model/Cart/Data/CartItemFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ private function createEnteredOptions(array $options): array
4545
{
4646
return \array_map(
4747
function (array $option) {
48-
if (!isset($option['id'], $option['value'])) {
48+
if (!isset($option['uid'], $option['value'])) {
4949
throw new InputException(
50-
__('Required fields are not present EnteredOption.id, EnteredOption.value')
50+
__('Required fields are not present EnteredOption.uid, EnteredOption.value')
5151
);
5252
}
53-
return new EnteredOption($option['id'], $option['value']);
53+
return new EnteredOption($option['uid'], $option['value']);
5454
},
5555
$options
5656
);

app/code/Magento/Quote/Model/Cart/Data/EnteredOption.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ class EnteredOption
1515
/**
1616
* @var string
1717
*/
18-
private $id;
18+
private $uid;
1919

2020
/**
2121
* @var string
2222
*/
2323
private $value;
2424

2525
/**
26-
* @param string $id
26+
* @param string $uid
2727
* @param string $value
2828
*/
29-
public function __construct(string $id, string $value)
29+
public function __construct(string $uid, string $value)
3030
{
31-
$this->id = $id;
31+
$this->uid = $uid;
3232
$this->value = $value;
3333
}
3434

@@ -37,9 +37,9 @@ public function __construct(string $id, string $value)
3737
*
3838
* @return string
3939
*/
40-
public function getId(): string
40+
public function getUid(): string
4141
{
42-
return $this->id;
42+
return $this->uid;
4343
}
4444

4545
/**

app/code/Magento/QuoteBundleOptions/Model/Cart/BuyRequest/BundleDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function execute(CartItem $cartItem): array
4545
//for bundle options with custom quantity
4646
foreach ($cartItem->getEnteredOptions() as $option) {
4747
// phpcs:ignore Magento2.Functions.DiscouragedFunction
48-
$optionData = \explode('/', base64_decode($option->getId()));
48+
$optionData = \explode('/', base64_decode($option->getUid()));
4949

5050
if ($this->isProviderApplicable($optionData) === false) {
5151
continue;

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ input CartItemInput {
5353
sku: String!
5454
quantity: Float!
5555
parent_sku: String,
56-
selected_options: [String!]
56+
selected_options: [ID!]
5757
entered_options: [EnteredOptionInput!]
5858
}
5959

@@ -319,11 +319,6 @@ type SetGuestEmailOnCartOutput {
319319
cart: Cart!
320320
}
321321

322-
input EnteredOptionInput {
323-
id: ID! @doc(description: "base64 encoded option ID")
324-
value: String!
325-
}
326-
327322
type SimpleCartItem implements CartItemInterface @doc(description: "Simple Cart Item") {
328323
customizable_options: [SelectedCustomizableOption] @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\CustomizableOptions")
329324
}

app/code/Magento/Wishlist/Model/Wishlist/BuyRequest/CustomizableOptionDataProvider.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,25 @@ public function execute(WishlistItem $wishlistItemData, ?int $productId): array
3131
continue;
3232
}
3333

34-
[, $optionId, $optionValue] = $optionData;
34+
[$optionType, $optionId, $optionValue] = $optionData;
3535

36-
$customizableOptionsData[$optionId][] = $optionValue;
36+
if ($optionType == self::PROVIDER_OPTION_TYPE) {
37+
$customizableOptionsData[$optionId][] = $optionValue;
38+
}
3739
}
3840

3941
foreach ($wishlistItemData->getEnteredOptions() as $option) {
40-
$optionData = \explode('/', base64_decode($option->getId()));
42+
$optionData = \explode('/', base64_decode($option->getUid()));
4143

4244
if ($this->isProviderApplicable($optionData) === false) {
4345
continue;
4446
}
4547

46-
[, $optionId] = $optionData;
48+
[$optionType, $optionId] = $optionData;
4749

48-
$customizableOptionsData[$optionId][] = $option->getValue();
50+
if ($optionType == self::PROVIDER_OPTION_TYPE) {
51+
$customizableOptionsData[$optionId][] = $option->getValue();
52+
}
4953
}
5054

5155
if (empty($customizableOptionsData)) {

app/code/Magento/Wishlist/Model/Wishlist/Data/EnteredOption.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ class EnteredOption
1515
/**
1616
* @var string
1717
*/
18-
private $id;
18+
private $uid;
1919

2020
/**
2121
* @var string
2222
*/
2323
private $value;
2424

2525
/**
26-
* @param string $id
26+
* @param string $uid
2727
* @param string $value
2828
*/
29-
public function __construct(string $id, string $value)
29+
public function __construct(string $uid, string $value)
3030
{
31-
$this->id = $id;
31+
$this->uid = $uid;
3232
$this->value = $value;
3333
}
3434

@@ -37,9 +37,9 @@ public function __construct(string $id, string $value)
3737
*
3838
* @return string
3939
*/
40-
public function getId(): string
40+
public function getUid(): string
4141
{
42-
return $this->id;
42+
return $this->uid;
4343
}
4444

4545
/**

app/code/Magento/Wishlist/Model/Wishlist/Data/WishlistItemFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ private function createEnteredOptions(array $options): array
4545
{
4646
return \array_map(
4747
function (array $option) {
48-
if (!isset($option['id'], $option['value'])) {
48+
if (!isset($option['uid'], $option['value'])) {
4949
throw new InputException(
50-
__('Required fields are not present EnteredOption.id, EnteredOption.value')
50+
__('Required fields are not present EnteredOption.uid, EnteredOption.value')
5151
);
5252
}
53-
return new EnteredOption($option['id'], $option['value']);
53+
return new EnteredOption($option['uid'], $option['value']);
5454
},
5555
$options
5656
);

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ input WishlistItemInput @doc(description: "Defines the items to add to a wish li
4343
sku: String @doc(description: "The SKU of the product to add. For complex product types, specify the child product SKU")
4444
quantity: Float @doc(description: "The amount or number of items to add")
4545
parent_sku: String @doc(description: "For complex product types, the SKU of the parent product")
46-
selected_options: [String!] @doc(description: "An array of strings corresponding to options the customer selected")
46+
selected_options: [ID!] @doc(description: "An array of strings corresponding to options the customer selected")
4747
entered_options: [EnteredOptionInput!] @doc(description: "An array of options that the customer entered")
4848
}
4949

@@ -52,11 +52,6 @@ type AddProductsToWishlistOutput @doc(description: "Contains the customer's wish
5252
userInputErrors:[CheckoutUserInputError]! @doc(description: "An array of errors encountered while adding products to a wish list")
5353
}
5454

55-
input EnteredOptionInput @doc(description: "Defines a customer-entered option") {
56-
id: String! @doc(description: "A base64 encoded ID")
57-
value: String! @doc(description: "Text the customer entered")
58-
}
59-
6055
type RemoveProductsFromWishlistOutput @doc(description: "Contains the customer's wish list and any errors encountered") {
6156
wishlist: Wishlist! @doc(description: "Contains the wish list with after items were successfully deleted")
6257
userInputErrors:[CheckoutUserInputError]! @doc(description:"An array of errors encountered while deleting products from a wish list")
@@ -66,7 +61,7 @@ input WishlistItemUpdateInput @doc(description: "Defines updates to items in a w
6661
wishlist_item_id: ID @doc(description: "The ID of the wishlist item to update")
6762
quantity: Float @doc(description: "The new amount or number of this item")
6863
description: String @doc(description: "Describes the update")
69-
selected_options: [String!] @doc(description: "An array of strings corresponding to options the customer selected")
64+
selected_options: [ID!] @doc(description: "An array of strings corresponding to options the customer selected")
7065
entered_options: [EnteredOptionInput!] @doc(description: "An array of options that the customer entered")
7166
}
7267

0 commit comments

Comments
 (0)