2020-07-07 10:14:12 +00:00
|
|
|
import {
|
|
|
|
collectionDetailsFragment,
|
|
|
|
collectionFragment,
|
|
|
|
collectionProductFragment
|
|
|
|
} from "@saleor/fragments/collections";
|
2020-05-14 09:30:32 +00:00
|
|
|
import makeQuery from "@saleor/hooks/makeQuery";
|
2019-06-19 14:40:52 +00:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
|
|
import { TypedQuery } from "../queries";
|
|
|
|
import {
|
|
|
|
CollectionDetails,
|
|
|
|
CollectionDetailsVariables
|
|
|
|
} from "./types/CollectionDetails";
|
|
|
|
import {
|
|
|
|
CollectionList,
|
|
|
|
CollectionListVariables
|
|
|
|
} from "./types/CollectionList";
|
|
|
|
|
|
|
|
export const collectionList = gql`
|
|
|
|
${collectionFragment}
|
|
|
|
query CollectionList(
|
|
|
|
$first: Int
|
|
|
|
$after: String
|
|
|
|
$last: Int
|
|
|
|
$before: String
|
2019-09-11 14:00:02 +00:00
|
|
|
$filter: CollectionFilterInput
|
2019-12-17 17:13:56 +00:00
|
|
|
$sort: CollectionSortingInput
|
2019-06-19 14:40:52 +00:00
|
|
|
) {
|
2019-09-11 14:00:02 +00:00
|
|
|
collections(
|
|
|
|
first: $first
|
|
|
|
after: $after
|
|
|
|
before: $before
|
|
|
|
last: $last
|
|
|
|
filter: $filter
|
2019-12-17 17:13:56 +00:00
|
|
|
sortBy: $sort
|
2019-09-11 14:00:02 +00:00
|
|
|
) {
|
2019-06-19 14:40:52 +00:00
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
...CollectionFragment
|
|
|
|
products {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pageInfo {
|
|
|
|
endCursor
|
|
|
|
hasNextPage
|
|
|
|
hasPreviousPage
|
|
|
|
startCursor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2019-12-17 17:13:56 +00:00
|
|
|
export const useCollectionListQuery = makeQuery<
|
2019-06-19 14:40:52 +00:00
|
|
|
CollectionList,
|
|
|
|
CollectionListVariables
|
|
|
|
>(collectionList);
|
|
|
|
|
|
|
|
export const collectionDetails = gql`
|
|
|
|
${collectionDetailsFragment}
|
|
|
|
${collectionProductFragment}
|
|
|
|
query CollectionDetails(
|
|
|
|
$id: ID!
|
|
|
|
$first: Int
|
|
|
|
$after: String
|
|
|
|
$last: Int
|
|
|
|
$before: String
|
|
|
|
) {
|
|
|
|
collection(id: $id) {
|
|
|
|
...CollectionDetailsFragment
|
|
|
|
products(first: $first, after: $after, before: $before, last: $last) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
...CollectionProductFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pageInfo {
|
|
|
|
endCursor
|
|
|
|
hasNextPage
|
|
|
|
hasPreviousPage
|
|
|
|
startCursor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedCollectionDetailsQuery = TypedQuery<
|
|
|
|
CollectionDetails,
|
|
|
|
CollectionDetailsVariables
|
|
|
|
>(collectionDetails);
|