saleor-dashboard/src/attributes/queries.ts
Dominik Żegleń 7770ae34df
Add metadata (#670)
* Add metadata editor component

* Add tests

* Fix plurals

* Use pascal case in selectors

* Update product metadata

* Add metadata handler decorator

* Update snapshots

* wip

* Remove operation provider component

* Add metadata to collections

* Add metadata editor to variant

* Add metadata editor to categories

* Add metadata to product types

* Simplify code

* Add metadata to attributes

* Drop maybe

* Rename Metadata to MetadataFragment

* Update changelog and snapshots
2020-08-28 14:45:11 +02:00

66 lines
1.4 KiB
TypeScript

import {
attributeDetailsFragment,
attributeFragment
} from "@saleor/fragments/attributes";
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
import makeQuery from "@saleor/hooks/makeQuery";
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<
AttributeDetails,
AttributeDetailsVariables
>(attributeDetails);
const attributeList = gql`
${attributeFragment}
${pageInfoFragment}
query AttributeList(
$filter: AttributeFilterInput
$before: String
$after: String
$first: Int
$last: Int
$sort: AttributeSortingInput
) {
attributes(
filter: $filter
before: $before
after: $after
first: $first
last: $last
sortBy: $sort
) {
edges {
node {
...AttributeFragment
values {
id
name
slug
}
}
}
pageInfo {
...PageInfoFragment
}
}
}
`;
export const useAttributeListQuery = makeQuery<
AttributeList,
AttributeListVariables
>(attributeList);