saleor-dashboard/src/attributes/queries.ts

67 lines
1.4 KiB
TypeScript
Raw Normal View History

import {
attributeDetailsFragment,
attributeFragment
} from "@saleor/fragments/attributes";
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
import makeQuery from "@saleor/hooks/makeQuery";
2019-08-09 10:17:04 +00:00
import gql from "graphql-tag";
import {
AttributeDetails,
AttributeDetailsVariables
} from "./types/AttributeDetails";
import { AttributeList, AttributeListVariables } from "./types/AttributeList";
const attributeDetails = gql`
${attributeDetailsFragment}
query AttributeDetails($id: ID!) {
attribute(id: $id) {
...AttributeDetailsFragment
}
}
`;
export const useAttributeDetailsQuery = makeQuery<
2019-08-09 10:17:04 +00:00
AttributeDetails,
AttributeDetailsVariables
>(attributeDetails);
const attributeList = gql`
${attributeFragment}
${pageInfoFragment}
query AttributeList(
2019-09-10 15:32:47 +00:00
$filter: AttributeFilterInput
2019-08-09 10:17:04 +00:00
$before: String
$after: String
$first: Int
$last: Int
2019-12-17 17:13:56 +00:00
$sort: AttributeSortingInput
2019-08-09 10:17:04 +00:00
) {
attributes(
2019-09-10 15:32:47 +00:00
filter: $filter
2019-08-09 10:17:04 +00:00
before: $before
after: $after
first: $first
last: $last
2019-12-17 17:13:56 +00:00
sortBy: $sort
2019-08-09 10:17:04 +00:00
) {
edges {
node {
...AttributeFragment
2019-09-25 09:26:46 +00:00
values {
id
name
slug
}
2019-08-09 10:17:04 +00:00
}
}
pageInfo {
...PageInfoFragment
}
}
}
`;
2019-12-17 17:13:56 +00:00
export const useAttributeListQuery = makeQuery<
2019-08-09 10:17:04 +00:00
AttributeList,
AttributeListVariables
>(attributeList);