-
Notifications
You must be signed in to change notification settings - Fork 153
Updated GraphQl Compare List Proposal #430
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
Conversation
|
||
type CompareList { | ||
list_id: ID! @doc(description: " Compare list id") | ||
list_id: ID! @doc(description: "Compare list id") |
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.
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. |
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.
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") |
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.
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") |
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.
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 |
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 new field catalog_compare_list_id
.
|
||
This dependency can be solved by managing the compare list state in a new table | ||
``` | ||
catalog_compare_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.
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.
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.
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.
design-documents/graph-ql/coverage/catalog/compare-list.graphqls
Outdated
Show resolved
Hide resolved
type CompareList { | ||
list_id: ID! @doc(description: " Compare list id") | ||
uid: ID! @doc(description: "Compare list id") | ||
items: [ComparableItem] @doc(description: "Comparable products") |
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.
Would be good to make the following changes to ComparableItem in this PR
- Add uid field, so that clients can understand when they receive new items
- Rename priceRange to price_range
- Can we have media_gallery: [MediaGalleryInterface]! instead of images: [ProductImage]!?
- 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.
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.
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.
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.
Figured that the reason for #3 ProductImage is, MediaGalleryInterface encompasses even videos. Videos are not supported in Product compare.
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! |
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.
After discussion with @cpartica and @melnikovi, decided to return ProductInterface here.
Problem
Solution
Requested Reviewers
@akaplya @melnikovi @cpartica @DrewML @nrkapoor @mauragcyrus