-
Notifications
You must be signed in to change notification settings - Fork 9.4k
[GraphQl] Add wishlist item to cart Implementation #31584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GraphQl] Add wishlist item to cart Implementation #31584
Conversation
Hi @shikhamis11. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Added Test for wishlist items add to cart
@magento run all tests |
@magento give me test instance |
Hi @shikhamis11. Thank you for your request. I'm working on Magento instance for you. |
Hi @shikhamis11, here is your Magento Instance: https://f0f79f6ed3c10bbb471a47d4dda1253d.instances.magento-community.engineering |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comments on the attribute descriptions.
@@ -23,7 +23,8 @@ type WishlistOutput @doc(description: "Deprecated: `Wishlist` type should be use | |||
} | |||
|
|||
type Wishlist { | |||
id: ID @doc(description: "The unique ID for a `Wishlist` object") | |||
id: ID @deprecated(reason: "Use `wishlists.uid` instead") @doc(description: "The unique ID for a `Wishlist` object") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the reason be "Use Wishlist.uid
instead"? If yes, I'd prefer the reason to be "Use uid
instead", since both attributes are in the same data type.
@@ -35,7 +36,8 @@ type Wishlist { | |||
} | |||
|
|||
interface WishlistItemInterface @typeResolver(class: "Magento\\WishlistGraphQl\\Model\\Resolver\\Type\\WishlistItemType") { | |||
id: ID! @doc(description: "The unique ID for a `WishlistItemInterface` object") | |||
id: ID! @deprecated(reason: "Use `WishlistItemInterface.uid` instead") @doc(description: "The unique ID for a `WishlistItemInterface` object") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above regarding the reason text. "Use uid
instead"
@@ -60,6 +62,15 @@ type Mutation { | |||
addProductsToWishlist(wishlistId: ID!, wishlistItems: [WishlistItemInput!]!): AddProductsToWishlistOutput @doc(description: "Adds one or more products to the specified wish list. This mutation supports all product types") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\AddProductsToWishlist") | |||
removeProductsFromWishlist(wishlistId: ID!, wishlistItemsIds: [ID!]!): RemoveProductsFromWishlistOutput @doc(description: "Removes one or more products from the specified wish list") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\RemoveProductsFromWishlist") | |||
updateProductsInWishlist(wishlistId: ID!, wishlistItems: [WishlistItemUpdateInput!]!): UpdateProductsInWishlistOutput @doc(description: "Updates one or more products in the specified wish list") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\UpdateProductsInWishlist") | |||
addWishlistItemsToCart( | |||
wishlistUid: ID!, @doc(description: "The unique ID of the requisition list") | |||
wishlistItemUids: [ID!] @doc(description: "An array of UIDs presenting products to be added to the cart. If no UIDs are specified, all items in the wishlist will be added to the cart") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wishlistItemUids: [ID!] @doc(description: "An array of UIDs presenting products to be added to the cart. If no UIDs are specified, all items in the wishlist will be added to the cart") | |
wishlistItemUids: [ID!] @doc(description: "An array of UIDs representing products to be added to the cart. If no UIDs are specified, all items in the wishlist will be added to the cart") |
addWishlistItemsToCart( | ||
wishlistUid: ID!, @doc(description: "The unique ID of the requisition list") | ||
wishlistItemUids: [ID!] @doc(description: "An array of UIDs presenting products to be added to the cart. If no UIDs are specified, all items in the wishlist will be added to the cart") | ||
): AddWishlistItemsToCartOutput @resolver(class: "Magento\\WishlistGraphQl\\Model\\Resolver\\Wishlist\\AddToCart") @doc(description: "Add items in the wishlist to the customer's cart") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
): AddWishlistItemsToCartOutput @resolver(class: "Magento\\WishlistGraphQl\\Model\\Resolver\\Wishlist\\AddToCart") @doc(description: "Add items in the wishlist to the customer's cart") | |
): AddWishlistItemsToCartOutput @resolver(class: "Magento\\WishlistGraphQl\\Model\\Resolver\\Wishlist\\AddToCart") @doc(description: "Add items in the specified wishlist to the customer's cart") |
|
||
type AddWishlistItemsToCartOutput { | ||
status: Boolean! | ||
add_wishlist_items_to_cart_user_errors: [CartUserInputError!]! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_wishlist_items_to_cart_user_errors: [CartUserInputError!]! | |
add_wishlist_items_to_cart_user_errors: [CartUserInputError!]! @doc(description: "An array of errors encountered while adding products to the customer's cart") |
} | ||
|
||
type AddWishlistItemsToCartOutput { | ||
status: Boolean! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status: Boolean! | |
status: Boolean! @doc(description: "Indicates whether the attempt to add items to the customer's cart was successful") |
@magento run Static Tests |
These are my opinions only. It's up to Maura and the development team to decide whether to accept or reject my opinions.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! couple of comments needs to be addressed. Thanks!
@@ -23,7 +23,8 @@ type WishlistOutput @doc(description: "Deprecated: `Wishlist` type should be use | |||
} | |||
|
|||
type Wishlist { | |||
id: ID @doc(description: "The unique ID for a `Wishlist` object") | |||
id: ID @deprecated(reason: "Use `uid` instead") @doc(description: "The unique ID for a `Wishlist` object") | |||
uid: ID @doc(description: "The unique ID for a `Wishlist` object") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shikhamis11 Good work on the PR! I see you have introduced uid for wishlist, but it will complicate things at this point as it will welcome conflicts on existing mutations. @mauragcyrus We need to have a follow up story, if needed. @shikhamis11 Can you remove this uid here and on the wishlist item. If there are any concerns please reply. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prabhuram93 thanks for review. I added uid
for Wishlist
and WishlistItemInterface
as in addWishlistItemsToCart
mutation we require wishlistUid
& wishlistItemUids
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah agree. I think that's confusing. I will work with @cpartica on renaming that to wishlistId & wishlistItemItds.
@@ -35,7 +36,8 @@ type Wishlist { | |||
} | |||
|
|||
interface WishlistItemInterface @typeResolver(class: "Magento\\WishlistGraphQl\\Model\\Resolver\\Type\\WishlistItemType") { | |||
id: ID! @doc(description: "The unique ID for a `WishlistItemInterface` object") | |||
id: ID! @deprecated(reason: "Use `uid` instead") @doc(description: "The unique ID for a `WishlistItemInterface` object") | |||
uid: ID! @doc(description: "The unique ID for a `WishlistItemInterface` object") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even this needs to be removed.
|
||
/** @var AddProductsToCartOutput $addProductsToCartOutput */ | ||
$addProductsToCartOutput = $this->addProductsToCartService->execute($maskedCartId, $cartItems); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we removing the items from the wishlist after it is added to the cart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually not removing wishlist items now. I missed that part. I will push changes for this today
@magento run all tests |
Fixed test failure
@magento run all tests |
@@ -60,6 +60,15 @@ type Mutation { | |||
addProductsToWishlist(wishlistId: ID!, wishlistItems: [WishlistItemInput!]!): AddProductsToWishlistOutput @doc(description: "Adds one or more products to the specified wish list. This mutation supports all product types") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\AddProductsToWishlist") | |||
removeProductsFromWishlist(wishlistId: ID!, wishlistItemsIds: [ID!]!): RemoveProductsFromWishlistOutput @doc(description: "Removes one or more products from the specified wish list") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\RemoveProductsFromWishlist") | |||
updateProductsInWishlist(wishlistId: ID!, wishlistItems: [WishlistItemUpdateInput!]!): UpdateProductsInWishlistOutput @doc(description: "Updates one or more products in the specified wish list") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\UpdateProductsInWishlist") | |||
addWishlistItemsToCart( | |||
wishlistId: ID!, @doc(description: "The unique ID of the requisition list") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description should be "The unique ID of the wish list"
Shouldn't the field names match with what the architectural schema dictates : "wishlistUid" and "wishlistItemUids" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @dthampy thanks for review
I have updated wishlistUid
and wishlistItemUids
to wishlistId
and wishlistItemIds
as per change request by @prabhuram93
#31584 (comment)
@magento run all tests |
This pull request is being processed internally. Please do not add any more commits on this PR. |
Hi @shikhamis11, thank you for your contribution! |
Description (*)
Implement coverage for this new mutation
https://github.com/magento/architecture/blob/master/design-documents/graph-ql/coverage/customer/Wishlist.graphqls
addWishlistItemsToCart( wishlistUid: ID!, @doc(description: "unique Id of wishlist") wishlistItemUids: [ID!> @doc(description: "Optional param. selected wish list items that are to be added") ): AddWishlistItemsToCartOutput @doc(description: "Add Requisition List Items To Customer Cart")
AC
Related Pull Requests
https://github.com/magento/partners-magento2ee/pull/449
Fixed Issues (if relevant)
Contribution checklist (*)