add searchQuery

Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
Loan Laux 2021-05-12 13:57:58 +04:00
parent 6f0dfb78f3
commit 76bb0c7e5d
No known key found for this signature in database
GPG Key ID: AF9E9BD6548AD52E
2 changed files with 6 additions and 5 deletions

View File

@ -7,15 +7,15 @@ export const getSearchVariables = ({
categoryId,
sort,
}: SearchProductsInput) => {
let query = ''
let searchQuery = ''
let tagIdsParam = {}
if (search) {
query += `product_type:${search} OR title:${search} OR tag:${search}`
searchQuery += search
}
if (brandId) {
query += `${search ? ' AND ' : ''}vendor:${brandId}`
searchQuery += `${search ? ' ' : ''}${brandId}`
}
if (categoryId) {
@ -25,8 +25,7 @@ export const getSearchVariables = ({
}
return {
// categoryId,
// query,
searchQuery,
...tagIdsParam,
...getSortVariables(sort, !!categoryId),
}

View File

@ -49,6 +49,7 @@ catalogItems(
sortBy: $sortBy
tagIds: $tagIds
shopIds: $shopIds
searchQuery: $searchQuery
) {
${catalogItemsConnection}
}
@ -60,6 +61,7 @@ const catalogItemsQuery = /* GraphQL */ `
$sortBy: CatalogItemSortByField = updatedAt
$tagIds: [ID]
$shopIds: [ID]!
$searchQuery: String
) {
${catalogItemsFragment}
}