@faststore/api 1.12.6 → 1.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/api.cjs.development.js +15 -1
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +15 -1
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/search/types/ProductSearchResult.d.ts +1 -1
- package/package.json +2 -2
- package/src/platforms/vtex/clients/search/types/ProductSearchResult.ts +1 -1
- package/src/platforms/vtex/resolvers/query.ts +16 -0
- package/src/platforms/vtex/resolvers/searchResult.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"graphql": "^15.6.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "52dd802b9e028d3860603e47387f250a24f264ce"
|
|
50
50
|
}
|
|
@@ -53,6 +53,22 @@ export const Query = {
|
|
|
53
53
|
|
|
54
54
|
const sku = await skuLoader.load(skuId)
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Here be dragons 🦄🦄🦄
|
|
58
|
+
*
|
|
59
|
+
* In some cases, the slug has a valid skuId for a different
|
|
60
|
+
* product. This condition makes sure that the fetched sku
|
|
61
|
+
* is the one we actually asked for
|
|
62
|
+
* */
|
|
63
|
+
if (
|
|
64
|
+
slug && sku.isVariantOf.linkText &&
|
|
65
|
+
!slug.startsWith(sku.isVariantOf.linkText)
|
|
66
|
+
) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Slug was set but the fetched sku does not satisfy the slug condition. slug: ${slug}, linkText: ${sku.isVariantOf.linkText}`,
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
56
72
|
return sku
|
|
57
73
|
} catch (err) {
|
|
58
74
|
if (slug == null) {
|
|
@@ -57,7 +57,7 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
|
|
|
57
57
|
sp.sendEvent({
|
|
58
58
|
type: 'search.query',
|
|
59
59
|
text: searchArgs.query,
|
|
60
|
-
misspelled: products.correction
|
|
60
|
+
misspelled: products.correction?.misspelled ?? false,
|
|
61
61
|
match: products.recordsFiltered,
|
|
62
62
|
operator: products.operator,
|
|
63
63
|
}).catch(console.error)
|