Skip to content

Conversation

prabhuram93
Copy link

@prabhuram93 prabhuram93 commented Sep 3, 2020

Problem

  • In Existing Implementation, Compare Lis doesn't have an id on its own. Its state is tied to Luma's session which should not be the case for GraphQl. Every new list entry expects a visitor_id in the database which is from Visitor session and cannot be mocked.
  • Existing proposal expects clients to generate list_id (Compare list id). This idea is debatable and can lead to data inconsistency.

Solution

  • Establish a list_id for each of the compare list. Clients will be able to create compare list to get a list_id. list_id can be used for future operations on the compare list

Requested Reviewers

@akaplya @melnikovi @cpartica @DrewML @nrkapoor @mauragcyrus


type CompareList {
list_id: ID! @doc(description: " Compare list id")
list_id: ID! @doc(description: "Compare list id")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
list_id: ID! @doc(description: "Compare list id")
uid: ID! @doc(description: "Compare list uid")


type Customer {
compare_list: CompareList @doc(description: "Active customers compare list")
compareList(id: ID): [CompareList] @doc(description: "Active customers compare list") #id is optional. Introduces the possibility of more than 1 compare list.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
compareList(id: ID): [CompareList] @doc(description: "Active customers compare list") #id is optional. Introduces the possibility of more than 1 compare list.
compare_list(uid: ID!): [CompareList]! @doc(description: "Active customers compare list") #id is optional. Introduces the possibility of more than 1 compare list.


type Query {
compareList(id: ID!): CompareList @doc(description: "Compare list")
compareList(id: ID!): [CompareList] @doc(description: "Compare list")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
compareList(id: ID!): [CompareList] @doc(description: "Compare list")
compare_list(uid: ID!): [CompareList]! @doc(description: "Compare list")

}

type Mutation {
createCompareList(items: [ID!]): CompareList @doc(description: "Creates a new compare list. For a logged in user, the created list is assigned to the user")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
createCompareList(items: [ID!]): CompareList @doc(description: "Creates a new compare list. For a logged in user, the created list is assigned to the user")
createCompareList(product_id: [ID!]): CompareList @doc(description: "Creates a new compare list. For a logged in user, the created list is assigned to the user")


Existing table structure for compare list
```
catalog_compare_item
Copy link
Member

Choose a reason for hiding this comment

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

Add new field catalog_compare_list_id.


This dependency can be solved by managing the compare list state in a new table
```
catalog_compare_list
Copy link
Member

Choose a reason for hiding this comment

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

Will only have the following fields: list_id, visitor_id. Not sure we can avoid having here visitor_id, we need somehow to make sure that catalog_compare_item.visitor_id is the same for all items related to a list.

Copy link
Author

Choose a reason for hiding this comment

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

visitor_id is generated based on Luma's session. so we cannot mock it. But it can be 0, which will imply the record is not created via Luma. And I see your point.We limit the new table to have two columns list_id, additional_data (json) and we can refer it back to the original table.

@melnikovi melnikovi added GraphQL needs update Author should update the proposal based on the feedback labels Sep 9, 2020
type CompareList {
list_id: ID! @doc(description: " Compare list id")
uid: ID! @doc(description: "Compare list id")
items: [ComparableItem] @doc(description: "Comparable products")
Copy link
Member

@melnikovi melnikovi Oct 15, 2020

Choose a reason for hiding this comment

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

Would be good to make the following changes to ComparableItem in this PR

  1. Add uid field, so that clients can understand when they receive new items
  2. Rename priceRange to price_range
  3. Can we have media_gallery: [MediaGalleryInterface]! instead of images: [ProductImage]!?
  4. Why do we need productId? If we expect that in some scenarios clients may need to load more product fields, we should probably expose ProductInterface.

Copy link
Author

Choose a reason for hiding this comment

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

Agree on 2 and 3. I will update the document. I think @paliarush exposed the id for the same reason on #4. I am okay with exposing ProductInterface, as I don't foresee N + 1 concerns here.

Copy link
Author

Choose a reason for hiding this comment

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

Figured that the reason for #3 ProductImage is, MediaGalleryInterface encompasses even videos. Videos are not supported in Product compare.

Prabhu Ram and others added 4 commits October 15, 2020 15:29
Co-authored-by: Igor Melnikov <imelnikov@magento.com>
Will have to decide between product_id and exposing product interface
…ace at the ComparableItem

Simplifies implementation and usage.
images: [ProductImage]! @doc(description: "Product Images")
values: [ProductAttribute]! @doc(description: "Product comparable attributes")
uid: ID!
product: ProductInterface!
Copy link
Author

Choose a reason for hiding this comment

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

After discussion with @cpartica and @melnikovi, decided to return ProductInterface here.

@melnikovi melnikovi self-requested a review October 22, 2020 18:16
@melnikovi melnikovi merged commit 1110740 into magento:master Oct 22, 2020
@melnikovi melnikovi removed the needs update Author should update the proposal based on the feedback label Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants