Skip to content

Commit

Permalink
Merge pull request #453 from vtex-apps/fix/shipping-option-cache
Browse files Browse the repository at this point in the history
Fix issue with shipping option filter that was being ignored
  • Loading branch information
thalytafabrine authored Mar 16, 2023
2 parents 15d4794 + 4eac6bc commit 8a9b65b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed
- Shipping options filter.

## [1.64.1] - 2023-02-27

### Added
Expand Down
15 changes: 9 additions & 6 deletions node/resolvers/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ export const queries = {
}
},
facets: async (_: any, args: FacetsInput, ctx: any) => {
const [shippingOptions, facets] = getShippingOptionsFromSelectedFacets(args.selectedFacets)

args.selectedFacets = facets

args = (await getCompatibilityArgsFromSelectedFacets(
ctx,
args
Expand All @@ -355,9 +359,7 @@ export const queries = {
// unnecessary field. It's is an object and breaks the @vtex/api cache
delete biggyArgs.selectedFacets

const [shippingOptions, facets] = getShippingOptionsFromSelectedFacets(selectedFacets)

const result = await intelligentSearchApi.facets({...biggyArgs, query: args.fullText}, buildAttributePath(facets), shippingOptions)
const result = await intelligentSearchApi.facets({...biggyArgs, query: args.fullText}, buildAttributePath(selectedFacets), shippingOptions)

if (ctx.vtex.tenant) {
ctx.translated = result.translated
Expand Down Expand Up @@ -492,6 +494,9 @@ export const queries = {
},

productSearch: async (_: any, args: ProductSearchInput, ctx: any) => {
const [shippingOptions, facets] = getShippingOptionsFromSelectedFacets(args.selectedFacets)
args.selectedFacets = facets

args = (await getCompatibilityArgsFromSelectedFacets(
ctx,
args
Expand Down Expand Up @@ -524,9 +529,7 @@ export const queries = {
// unnecessary field. It's is an object and breaks the @vtex/api cache
delete biggyArgs.selectedFacets

const [shippingOptions, facets] = getShippingOptionsFromSelectedFacets(selectedFacets)

const result = await intelligentSearchApi.productSearch({...biggyArgs}, buildAttributePath(facets), shippingOptions)
const result = await intelligentSearchApi.productSearch({...biggyArgs}, buildAttributePath(selectedFacets), shippingOptions)

if (ctx.vtex.tenant && !args.productOriginVtex) {
ctx.translated = result.translated
Expand Down
9 changes: 8 additions & 1 deletion node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,14 @@ [email protected]:
follow-redirects "^1.3.0"
is-buffer "^1.1.5"

axios@^0.21.1, axios@^0.21.2:
axios@^0.21.1:
version "0.21.4"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
dependencies:
follow-redirects "^1.14.0"

axios@^0.21.2:
version "0.21.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017"
integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==
Expand Down

0 comments on commit 8a9b65b

Please sign in to comment.