saleor-dashboard/src/searches/useProductSearch.ts
Dominik Żegleń 2a52eb581c
Update apollo to v3 (#1837)
* Update apollo to v3

* Fix imports

* Add generated file to ignored

* Use proper import

* Tidy up code

* Remove unused packages

* Fix tests
2022-02-21 14:32:38 +01:00

49 lines
1.1 KiB
TypeScript

import { gql } from "@apollo/client";
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch";
import {
SearchProducts,
SearchProductsVariables
} from "./types/SearchProducts";
export const searchProducts = gql`
${pageInfoFragment}
query SearchProducts($after: String, $first: Int!, $query: String!) {
search: products(after: $after, first: $first, filter: { search: $query }) {
edges {
node {
id
name
thumbnail {
url
}
variants {
id
name
sku
channelListings {
channel {
id
isActive
name
currencyCode
}
price {
amount
currency
}
}
}
}
}
pageInfo {
...PageInfoFragment
}
}
}
`;
export default makeTopLevelSearch<SearchProducts, SearchProductsVariables>(
searchProducts
);