saleor-dashboard/src/searches/useProductSearch.ts

33 lines
723 B
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import gql from "graphql-tag";
2019-11-19 16:50:40 +00:00
import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch";
2019-10-15 12:17:35 +00:00
import { pageInfoFragment } from "@saleor/queries";
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!) {
2019-10-15 12:17:35 +00:00
search: products(after: $after, first: $first, query: $query) {
2019-06-19 14:40:52 +00:00
edges {
node {
id
name
thumbnail {
url
}
}
}
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
);