Skip to content

Commit 04a637c

Browse files
committed
MC-22215: Add customerCart Query and cart_id changes to schema and related resolvers
- Fixed Review changes
1 parent 7879058 commit 04a637c

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
use Magento\Framework\Exception\NoSuchEntityException;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
1212
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
13-
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1413
use Magento\Framework\GraphQl\Query\ResolverInterface;
1514
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1615
use Magento\QuoteGraphQl\Model\Cart\CreateEmptyCartForCustomer;
1716
use Magento\Authorization\Model\UserContextInterface;
1817
use Magento\Quote\Api\CartManagementInterface;
19-
use Magento\Framework\Exception\LocalizedException;
2018

2119
/**
2220
* Get cart for the customer
@@ -72,13 +70,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
7270
}
7371

7472
/**
75-
* Checking if current user is logged
73+
* Checking if current user is logged in
7674
*
7775
* @param int|null $customerId
7876
* @param int|null $customerType
7977
* @return bool
8078
*/
81-
private function isCustomer(int $customerId, int $customerType): bool
79+
private function isCustomer(?int $customerId, ?int $customerType): bool
8280
{
8381
return !empty($customerId) && !empty($customerType) && $customerType !== UserContextInterface::USER_TYPE_GUEST;
8482
}

app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5151
}
5252

5353
/**
54-
* Fetch or create masked id for customer's active quote
54+
* Get masked id for cart
5555
*
5656
* @param int $quoteId
5757
* @return string
58-
* @throws \Magento\Framework\Exception\NoSuchEntityException
58+
* @throws GraphQlNoSuchEntityException
5959
*/
6060
private function getQuoteMaskId(int $quoteId): string
6161
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ type PlaceOrderOutput {
193193
}
194194

195195
type Cart {
196-
cart_id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart. The value can be an Int or String.")
196+
cart_id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart.")
197197
items: [CartItemInterface] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartItems")
198198
applied_coupon: AppliedCoupon @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupon") @doc(description:"An array of coupons that have been applied to the cart") @deprecated(reason: "Use applied_coupons instead ")
199199
applied_coupons: [AppliedCoupon] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupons") @doc(description:"An array of `AppliedCoupon` objects. Each object contains the `code` text attribute, which specifies the coupon code")

0 commit comments

Comments
 (0)