Skip to content
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

feat(recommendations): add "quantity" param to similars resolver #128

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- `groupByProduct` to `productRecommendations` query.
- `quantity` to `Recommendation.similars` resolver.
-
## [0.58.0] - 2023-12-07

### Added
Expand All @@ -24,7 +28,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added
- sponsoredProducts query.

## [0.54.0] - 2023-08-03

### Added
Expand Down
7 changes: 5 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Pagination item end
If true, uses isAvailablePerSalesChannel_ parameter on query with segment's sales channel. Will override any given salesChannel arg
</td></tr><tr><td colspan="2" align="right" valign="top">simulationBehavior</td><td valign="top"><a href="#simulationbehavior">SimulationBehavior</a></td><td>
If you want faster searches and do not care about most up to date prices and promotions, use skip value.
</td></tr><tr><td colspan="2" valign="top"><strong>productRecommendations</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" align="right" valign="top">identifier</td><td valign="top"><a href="#productuniqueidentifier">ProductUniqueIdentifier</a></td><td></td></tr><tr><td colspan="2" align="right" valign="top">type</td><td valign="top"><a href="#crossselinginputenum">CrossSelingInputEnum</a></td><td></td></tr><tr><td colspan="2" valign="top"><strong>productsByIdentifier</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" align="right" valign="top">field</td><td valign="top"><a href="#productuniqueidentifierfield">ProductUniqueIdentifierField</a>!</td><td></td></tr><tr><td colspan="2" align="right" valign="top">values</td><td valign="top">[<a href="#id">ID</a>!]</td><td></td></tr><tr><td colspan="2" align="right" valign="top">salesChannel</td><td valign="top"><a href="#string">String</a></td><td>
</td></tr><tr><td colspan="2" valign="top"><strong>productRecommendations</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" align="right" valign="top">identifier</td><td valign="top"><a href="#productuniqueidentifier">ProductUniqueIdentifier</a></td><td></td></tr><tr><td colspan="2" align="right" valign="top">type</td><td valign="top"><a href="#crossselinginputenum">CrossSelingInputEnum</a></td><td></td></tr><tr><td colspan="2" align="right" valign="top">groupByProduct</td><td valign="top"><a href="#productuniqueidentifier">Boolean</a></td><td></td></tr><tr><td colspan="2" valign="top"><strong>productsByIdentifier</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" align="right" valign="top">field</td><td valign="top"><a href="#productuniqueidentifierfield">ProductUniqueIdentifierField</a>!</td><td></td></tr><tr><td colspan="2" align="right" valign="top">values</td><td valign="top">[<a href="#id">ID</a>!]</td><td></td></tr><tr><td colspan="2" align="right" valign="top">salesChannel</td><td valign="top"><a href="#string">String</a></td><td>
Filter by availability at a specific sales channel.
</td></tr><tr><td colspan="2" valign="top"><strong>facets</strong></td><td valign="top"><a href="#facets">Facets</a></td><td>
Returns facets category
Expand Down Expand Up @@ -536,7 +536,7 @@ Indicates how the search-engine will deal with the fullText if there is more tha
<table><thead><tr><th align="left">Field</th><th align="right">Argument</th><th align="left">Type</th><th align="left">Description</th></tr></thead><tbody><tr><td colspan="2" valign="top"><strong>from</strong></td><td valign="top"><a href="#float">Float</a></td><td></td></tr><tr><td colspan="2" valign="top"><strong>to</strong></td><td valign="top"><a href="#float">Float</a></td><td></td></tr></tbody></table>

### Recommendation
<table><thead><tr><th align="left">Field</th><th align="right">Argument</th><th align="left">Type</th><th align="left">Description</th></tr></thead><tbody><tr><td colspan="2" valign="top"><strong>buy</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" valign="top"><strong>view</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" valign="top"><strong>similars</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr></tbody></table>
<table><thead><tr><th align="left">Field</th><th align="right">Argument</th><th align="left">Type</th><th align="left">Description</th></tr></thead><tbody><tr><td colspan="2" valign="top"><strong>buy</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" valign="top"><strong>view</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" valign="top"><strong>similars</strong></td><td valign="top">[<a href="#product">Product</a>]</td><td></td></tr><tr><td colspan="2" align="right" valign="top">quantity</td><td valign="top"><a href="#similarproductsquantityenum">SimilarProductsQuantityEnum</a></td><td></td></tr></tbody></table>

### Reference
<table><thead><tr><th align="left">Field</th><th align="right">Argument</th><th align="left">Type</th><th align="left">Description</th></tr></thead><tbody><tr><td colspan="2" valign="top"><strong>Key</strong></td><td valign="top"><a href="#string">String</a></td><td></td></tr><tr><td colspan="2" valign="top"><strong>Value</strong></td><td valign="top"><a href="#string">String</a></td><td></td></tr></tbody></table>
Expand Down Expand Up @@ -730,6 +730,9 @@ Returns all available items. Returns first if no item is available.
### SORT
<table><thead><th align="left">Value</th><th align="left">Description</th></thead><tbody><tr><td valign="top"><strong>ASC</strong></td><td></td></tr><tr><td valign="top"><strong>DESC</strong></td><td></td></tr></tbody></table>

### SimilarProductsQuantityEnum
<table><thead><th align="left">Value</th><th align="left">Description</th></thead><tbody><tr><td valign="top"><strong>ALL_AVAILABLE</strong></td><td>Returns all similar products by setting "groupByProduct" param to `false`</td></tr><tr><td valign="top"><strong>DEFAULT</strong></td><td>Returns 12 similar products by default</td></tr></tbody></table>

### SimulationBehavior
<table><thead><th align="left">Value</th><th align="left">Description</th></thead><tbody><tr><td valign="top"><strong>default</strong></td><td>
Does simulation on catalog as usual
Expand Down
1 change: 1 addition & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ type Query {
productRecommendations(
identifier: ProductUniqueIdentifier
type: CrossSelingInputEnum
groupByProduct: Boolean
): [Product] @cacheControl(scope: SEGMENT, maxAge: SHORT) @withSegment

productsByIdentifier(
Expand Down
13 changes: 12 additions & 1 deletion graphql/types/Product.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,23 @@ type Seller {
addToCartLink: String
sellerDefault: Boolean
commertialOffer: Offer
}

enum SimilarProductsQuantityEnum {
"""
Returns all similar products by setting "groupByProduct" param to `false`
"""
ALL_AVAILABLE
"""
Returns 12 similar products by default
"""
DEFAULT
}

type Recommendation {
buy: [Product]
view: [Product]
similars: [Product]
similars(quantity: SimilarProductsQuantityEnum): [Product]
}

type SKU {
Expand Down