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

View File

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