Skip to content

[GraphQl][Wishlist] Implementing a new Query of getting customer wishlist #29148

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

Merged

Conversation

eduard13
Copy link
Contributor

@eduard13 eduard13 commented Jul 15, 2020

Description (*)

This PR is a follow up of the following discussion, that is supposed to introduce a new Query, that will return the customer wishlists.
For CE version, it will always return a single wishlist (as there is no possibility to create more wishlists), so probably it doesn't make sense to implement any kind of logic to limit it to just 1 result. What do you think?

Related Pull Requests

https://github.com/magento/partners-magento2-infrastructure/pull/26

Fixed Issues (if relevant)

N/A

Manual testing scenarios (*)

Get Customer's wishlist

query {
  customer {
    wishlists {
      items_count
      sharing_code
      items_v2 {
        id
      	quantity
      	description
      	added_at
      }
    }
  }
}

Get Customer's wishlist (wishlist_v2)

query {
  customer {
    wishlist_v2(id: 0) {
      items_count
      sharing_code
      updated_at
      items_v2 {
        id
        quantity
        description
        added_at
        ... on DownloadableWishlistItem {
            links_v2 {
                id
                title
                sample_url
            }
            samples {
                id
                title
                sample_url
            }
        }
        ... on ConfigurableWishlistItem {
            child_sku
            configurable_options {
                id
                option_label
                value_id
		value_label
            }
        }
        ... on BundleWishlistItem {
            bundle_options {
                id
                label
                type
		values {
                    id
                    label
                    quantity
                    price
                }
            }
        }
      }
    }
  }
}

Questions or comments

The new Query will also be working for Multiple Wishlists, that will return all the customer's wishlists. Additionally it supports pagination, that may be used in EE version.

cc. @nrkapoor, @DrewML, @prabhuram93

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jul 15, 2020

Hi @eduard13. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

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.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 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

@magento-engcom-team magento-engcom-team added Component: WishlistGraphQl Release Line: 2.4 Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner labels Jul 15, 2020
@eduard13
Copy link
Contributor Author

@magento run all tests

@rogyar rogyar self-assigned this Jul 15, 2020
@nrkapoor nrkapoor added this to the 2.4.1 milestone Jul 15, 2020
@nrkapoor nrkapoor requested review from dthampy and avattam06 July 15, 2020 19:52
@rogyar
Copy link
Contributor

rogyar commented Jul 16, 2020

The general idea looks good to me. But before jumping into details, I believe the schema/architecture should be approved by @paliarush.

Alex, could you share your thoughts, please, on this implementation?
Appreciate your time.

@nrkapoor
Copy link

The general idea looks good to me. But before jumping into details, I believe the schema/architecture should be approved by @paliarush.

Alex, could you share your thoughts, please, on this implementation?
Appreciate your time.

@rogyar I believe the changes were approved but we still need to merge the architecture PR. @DrewML @paliarush can you merge the PR?

@DrewML
Copy link

DrewML commented Jul 16, 2020

Apologies for the lag - architecture PR here magento/architecture#403

array $args = null
) {
if (!$this->wishlistConfig->isEnabled()) {
throw new GraphQlInputException(__('The wishlist is not currently available.'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend some more meaningful explanation here. Otherwise, it might sound like EntityNotFound issue for some particular wishlist.

$collection->setPageSize($pageSize);
}

$result = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using more specific names for variables

Suggested change
$result = [];
$wishlists = [];

@rogyar
Copy link
Contributor

rogyar commented Jul 17, 2020

Hi @eduard13. Please, check my minor recommendations above. Thank you.

@eduard13
Copy link
Contributor Author

@magento run all tests

1 similar comment
@eduard13
Copy link
Contributor Author

@magento run all tests

@eduard13
Copy link
Contributor Author

eduard13 commented Jul 23, 2020

Hi @rogyar, your suggestions have been implemented.
Thank you.

@prabhuram93
Copy link
Contributor

@magento run all tests

Copy link
Contributor

@keharper keharper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly changing "wishlist to wish list", since that's how it's spelled in the Admin and Luma

wishlists(
pageSize: Int = 20 @doc(description: "Specifies the maximum number of results to return at once. This attribute is optional."),
currentPage: Int = 1 @doc(description: "Specifies which page of results to return. The default value is 1.")
): [Wishlist!]! @doc(description: "An array of wishlists. In Magento Open Source, customers are limited to one wishlist. The number of wishlists is not restricted for Magento Commerce") @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\CustomerWishlists")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
): [Wishlist!]! @doc(description: "An array of wishlists. In Magento Open Source, customers are limited to one wishlist. The number of wishlists is not restricted for Magento Commerce") @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\CustomerWishlists")
): [Wishlist!]! @doc(description: "An array of wishlists. In Magento Open Source, customers are limited to one wish list. The number of wish lists is configurable for Magento Commerce") @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\CustomerWishlists")

currentPage: Int = 1 @doc(description: "Specifies which page of results to return. The default value is 1.")
): [Wishlist!]! @doc(description: "An array of wishlists. In Magento Open Source, customers are limited to one wishlist. The number of wishlists is not restricted for Magento Commerce") @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\CustomerWishlists")
wishlist: Wishlist! @deprecated(reason: "Use `Customer.wishlists` or `Customer.wishlist_v2`") @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\CustomerWishlistResolver") @doc(description: "Contains a customer's wish lists") @cache(cacheable: false)
wishlist_v2(id: ID!): Wishlist @doc(description: "Retrieve the specified wishlist") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistById")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wishlist_v2(id: ID!): Wishlist @doc(description: "Retrieve the specified wishlist") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistById")
wishlist_v2(id: ID!): Wishlist @doc(description: "Retrieve the specified wish list") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistById")

@@ -492,3 +492,9 @@ type StoreConfig @doc(description: "The type contains information about a store
catalog_default_sort_by : String @doc(description: "Default Sort By.")
root_category_id: Int @doc(description: "The ID of the root category") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\RootCategoryId")
}

type SimpleWishlistItem implements WishlistItemInterface @doc(description: "A simple product wishlist Item") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type SimpleWishlistItem implements WishlistItemInterface @doc(description: "A simple product wishlist Item") {
type SimpleWishlistItem implements WishlistItemInterface @doc(description: "A simple product wish list item") {

type SimpleWishlistItem implements WishlistItemInterface @doc(description: "A simple product wishlist Item") {
}

type VirtualWishlistItem implements WishlistItemInterface @doc(description: "A virtual product wishlist item") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type VirtualWishlistItem implements WishlistItemInterface @doc(description: "A virtual product wishlist item") {
type VirtualWishlistItem implements WishlistItemInterface @doc(description: "A virtual product wish list item") {

@@ -68,3 +68,8 @@ type SelectedConfigurableOption {
value_id: Int!
value_label: String!
}

type ConfigurableWishlistItem implements WishlistItemInterface @doc(description: "A configurable product wishlist item"){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type ConfigurableWishlistItem implements WishlistItemInterface @doc(description: "A configurable product wishlist item"){
type ConfigurableWishlistItem implements WishlistItemInterface @doc(description: "A configurable product wish list item"){

@@ -64,3 +64,8 @@ type DownloadableProductSamples @doc(description: "DownloadableProductSamples de
sample_type: DownloadableFileTypeEnum @deprecated(reason: "`sample_url` serves to get the downloadable sample")
sample_file: String @deprecated(reason: "`sample_url` serves to get the downloadable sample")
}

type DownloadableWishlistItem implements WishlistItemInterface @doc(description: "A downloadable product wishlist item") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type DownloadableWishlistItem implements WishlistItemInterface @doc(description: "A downloadable product wishlist item") {
type DownloadableWishlistItem implements WishlistItemInterface @doc(description: "A downloadable product wish list item") {

@prabhuram93
Copy link
Contributor

@keharper I added your suggestions and linked infra PR.

@prabhuram93
Copy link
Contributor

@magento run all tests

@m2-assistant
Copy link

m2-assistant bot commented Aug 27, 2020

Hi @eduard13, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

9 participants