mirror of
https://github.com/vercel/commerce.git
synced 2025-07-01 02:41:22 +00:00
re: make search work with Saleor API (WIP)
This commit is contained in:
parent
65df8036ae
commit
a4cc1624c0
@ -9,7 +9,7 @@ const fetcher: Fetcher = async ({
|
||||
query,
|
||||
}) => {
|
||||
return handleFetchResponse(
|
||||
await fetch(url, {
|
||||
await fetch(url!, {
|
||||
method,
|
||||
body: JSON.stringify({ query, variables }),
|
||||
headers: {
|
||||
|
@ -7,19 +7,9 @@ export const getSearchVariables = ({
|
||||
categoryId,
|
||||
sort,
|
||||
}: SearchProductsInput) => {
|
||||
let query = ''
|
||||
|
||||
if (search) {
|
||||
query += `product_type:${search} OR title:${search} OR tag:${search}`
|
||||
}
|
||||
|
||||
if (brandId) {
|
||||
query += `${search ? ' AND ' : ''}vendor:${brandId}`
|
||||
}
|
||||
|
||||
return {
|
||||
categoryId,
|
||||
query,
|
||||
filter: { search },
|
||||
...getSortVariables(sort, !!categoryId),
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,10 @@ export const productConnection = /* GraphQL */ `
|
||||
const getAllProductsQuery = /* GraphQL */ `
|
||||
query getAllProducts(
|
||||
$first: Int = 100
|
||||
$filter: ProductFilterInput
|
||||
$channel: String = "default-channel"
|
||||
) {
|
||||
products(first: $first, channel: $channel) {
|
||||
products(first: $first, channel: $channel, filter: $filter) {
|
||||
...productConnnection
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user