saleor-dashboard/src/searches/useProductSearch.ts

50 lines
1.1 KiB
TypeScript
Raw Normal View History

import { pageInfoFragment } from "@saleor/fragments/pageInfo";
2019-11-19 16:50:40 +00:00
import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch";
import gql from "graphql-tag";
2019-06-19 14:40:52 +00:00
import {
SearchProducts,
SearchProductsVariables
} from "./types/SearchProducts";
export const searchProducts = gql`
2019-10-15 12:17:35 +00:00
${pageInfoFragment}
2019-06-19 14:40:52 +00:00
query SearchProducts($after: String, $first: Int!, $query: String!) {
2020-01-09 11:13:24 +00:00
search: products(after: $after, first: $first, filter: { search: $query }) {
2019-06-19 14:40:52 +00:00
edges {
node {
id
name
thumbnail {
url
}
variants {
id
name
sku
channelListings {
channel {
id
isActive
name
currencyCode
}
price {
amount
currency
}
}
}
2019-06-19 14:40:52 +00:00
}
}
2019-10-15 12:17:35 +00:00
pageInfo {
...PageInfoFragment
}
2019-06-19 14:40:52 +00:00
}
}
`;
2019-11-19 16:50:40 +00:00
export default makeTopLevelSearch<SearchProducts, SearchProductsVariables>(
2019-06-19 14:40:52 +00:00
searchProducts
);