2022-02-21 13:32:38 +00:00
|
|
|
import { gql } from "@apollo/client";
|
2021-05-24 11:01:18 +00:00
|
|
|
import {
|
|
|
|
attributeDetailsFragment,
|
|
|
|
attributeValueListFragment
|
|
|
|
} from "@saleor/fragments/attributes";
|
2020-11-19 14:42:14 +00:00
|
|
|
import { attributeErrorFragment } from "@saleor/fragments/errors";
|
2021-05-24 11:01:18 +00:00
|
|
|
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
|
2020-08-28 12:45:11 +00:00
|
|
|
import makeMutation from "@saleor/hooks/makeMutation";
|
2019-08-09 10:17:04 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
AttributeBulkDelete,
|
|
|
|
AttributeBulkDeleteVariables
|
|
|
|
} from "./types/AttributeBulkDelete";
|
|
|
|
import {
|
|
|
|
AttributeCreate,
|
|
|
|
AttributeCreateVariables
|
|
|
|
} from "./types/AttributeCreate";
|
|
|
|
import {
|
|
|
|
AttributeDelete,
|
|
|
|
AttributeDeleteVariables
|
|
|
|
} from "./types/AttributeDelete";
|
|
|
|
import {
|
|
|
|
AttributeUpdate,
|
|
|
|
AttributeUpdateVariables
|
|
|
|
} from "./types/AttributeUpdate";
|
|
|
|
import {
|
|
|
|
AttributeValueCreate,
|
|
|
|
AttributeValueCreateVariables
|
|
|
|
} from "./types/AttributeValueCreate";
|
|
|
|
import {
|
|
|
|
AttributeValueDelete,
|
|
|
|
AttributeValueDeleteVariables
|
|
|
|
} from "./types/AttributeValueDelete";
|
|
|
|
import {
|
|
|
|
AttributeValueReorder,
|
|
|
|
AttributeValueReorderVariables
|
|
|
|
} from "./types/AttributeValueReorder";
|
|
|
|
import {
|
|
|
|
AttributeValueUpdate,
|
|
|
|
AttributeValueUpdateVariables
|
|
|
|
} from "./types/AttributeValueUpdate";
|
|
|
|
|
|
|
|
const attributeBulkDelete = gql`
|
2020-11-19 14:42:14 +00:00
|
|
|
${attributeErrorFragment}
|
2019-08-09 10:17:04 +00:00
|
|
|
mutation AttributeBulkDelete($ids: [ID!]!) {
|
|
|
|
attributeBulkDelete(ids: $ids) {
|
2021-04-26 07:49:55 +00:00
|
|
|
errors {
|
2020-11-19 14:42:14 +00:00
|
|
|
...AttributeErrorFragment
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-28 12:45:11 +00:00
|
|
|
export const useAttributeBulkDeleteMutation = makeMutation<
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeBulkDelete,
|
|
|
|
AttributeBulkDeleteVariables
|
|
|
|
>(attributeBulkDelete);
|
|
|
|
|
|
|
|
const attributeDelete = gql`
|
2020-11-19 14:42:14 +00:00
|
|
|
${attributeErrorFragment}
|
2019-08-09 10:17:04 +00:00
|
|
|
mutation AttributeDelete($id: ID!) {
|
|
|
|
attributeDelete(id: $id) {
|
2021-04-26 07:49:55 +00:00
|
|
|
errors {
|
2020-11-19 14:42:14 +00:00
|
|
|
...AttributeErrorFragment
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-28 12:45:11 +00:00
|
|
|
export const useAttributeDeleteMutation = makeMutation<
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeDelete,
|
|
|
|
AttributeDeleteVariables
|
|
|
|
>(attributeDelete);
|
|
|
|
|
|
|
|
export const attributeUpdateMutation = gql`
|
|
|
|
${attributeDetailsFragment}
|
2020-11-19 14:42:14 +00:00
|
|
|
${attributeErrorFragment}
|
2019-08-09 10:17:04 +00:00
|
|
|
mutation AttributeUpdate($id: ID!, $input: AttributeUpdateInput!) {
|
|
|
|
attributeUpdate(id: $id, input: $input) {
|
|
|
|
attribute {
|
|
|
|
...AttributeDetailsFragment
|
|
|
|
}
|
2021-04-26 07:49:55 +00:00
|
|
|
errors {
|
2020-11-19 14:42:14 +00:00
|
|
|
...AttributeErrorFragment
|
2020-03-24 14:05:26 +00:00
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-28 12:45:11 +00:00
|
|
|
export const useAttributeUpdateMutation = makeMutation<
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeUpdate,
|
|
|
|
AttributeUpdateVariables
|
|
|
|
>(attributeUpdateMutation);
|
|
|
|
|
|
|
|
const attributeValueDelete = gql`
|
2021-05-24 11:01:18 +00:00
|
|
|
${attributeValueListFragment}
|
2020-11-19 14:42:14 +00:00
|
|
|
${attributeErrorFragment}
|
2021-05-24 11:01:18 +00:00
|
|
|
mutation AttributeValueDelete(
|
|
|
|
$id: ID!
|
|
|
|
$firstValues: Int
|
|
|
|
$afterValues: String
|
|
|
|
$lastValues: Int
|
|
|
|
$beforeValues: String
|
|
|
|
) {
|
2019-08-09 10:17:04 +00:00
|
|
|
attributeValueDelete(id: $id) {
|
|
|
|
attribute {
|
2021-05-24 11:01:18 +00:00
|
|
|
id
|
2021-06-02 19:11:30 +00:00
|
|
|
choices(
|
2021-05-24 11:01:18 +00:00
|
|
|
first: $firstValues
|
|
|
|
after: $afterValues
|
|
|
|
last: $lastValues
|
|
|
|
before: $beforeValues
|
|
|
|
) {
|
|
|
|
...AttributeValueListFragment
|
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
2021-04-26 07:49:55 +00:00
|
|
|
errors {
|
2020-11-19 14:42:14 +00:00
|
|
|
...AttributeErrorFragment
|
2020-03-24 14:05:26 +00:00
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-28 12:45:11 +00:00
|
|
|
export const useAttributeValueDeleteMutation = makeMutation<
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeValueDelete,
|
|
|
|
AttributeValueDeleteVariables
|
|
|
|
>(attributeValueDelete);
|
|
|
|
|
|
|
|
export const attributeValueUpdateMutation = gql`
|
2021-05-24 11:01:18 +00:00
|
|
|
${attributeValueListFragment}
|
2020-11-19 14:42:14 +00:00
|
|
|
${attributeErrorFragment}
|
2021-05-24 11:01:18 +00:00
|
|
|
mutation AttributeValueUpdate(
|
|
|
|
$id: ID!
|
2021-09-21 13:16:21 +00:00
|
|
|
$input: AttributeValueUpdateInput!
|
2021-05-24 11:01:18 +00:00
|
|
|
$firstValues: Int
|
|
|
|
$afterValues: String
|
|
|
|
$lastValues: Int
|
|
|
|
$beforeValues: String
|
|
|
|
) {
|
2019-08-09 10:17:04 +00:00
|
|
|
attributeValueUpdate(id: $id, input: $input) {
|
|
|
|
attribute {
|
2021-05-24 11:01:18 +00:00
|
|
|
id
|
2021-06-02 19:11:30 +00:00
|
|
|
choices(
|
2021-05-24 11:01:18 +00:00
|
|
|
first: $firstValues
|
|
|
|
after: $afterValues
|
|
|
|
last: $lastValues
|
|
|
|
before: $beforeValues
|
|
|
|
) {
|
|
|
|
...AttributeValueListFragment
|
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
2021-04-26 07:49:55 +00:00
|
|
|
errors {
|
2020-11-19 14:42:14 +00:00
|
|
|
...AttributeErrorFragment
|
2020-03-24 14:05:26 +00:00
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-28 12:45:11 +00:00
|
|
|
export const useAttributeValueUpdateMutation = makeMutation<
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeValueUpdate,
|
|
|
|
AttributeValueUpdateVariables
|
|
|
|
>(attributeValueUpdateMutation);
|
|
|
|
|
|
|
|
export const attributeValueCreateMutation = gql`
|
2021-05-24 11:01:18 +00:00
|
|
|
${attributeValueListFragment}
|
2020-11-19 14:42:14 +00:00
|
|
|
${attributeErrorFragment}
|
2021-05-24 11:01:18 +00:00
|
|
|
mutation AttributeValueCreate(
|
|
|
|
$id: ID!
|
|
|
|
$input: AttributeValueCreateInput!
|
|
|
|
$firstValues: Int
|
|
|
|
$afterValues: String
|
|
|
|
$lastValues: Int
|
|
|
|
$beforeValues: String
|
|
|
|
) {
|
2019-08-09 10:17:04 +00:00
|
|
|
attributeValueCreate(attribute: $id, input: $input) {
|
|
|
|
attribute {
|
2021-05-24 11:01:18 +00:00
|
|
|
id
|
2021-06-02 19:11:30 +00:00
|
|
|
choices(
|
2021-05-24 11:01:18 +00:00
|
|
|
first: $firstValues
|
|
|
|
after: $afterValues
|
|
|
|
last: $lastValues
|
|
|
|
before: $beforeValues
|
|
|
|
) {
|
|
|
|
...AttributeValueListFragment
|
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
2021-04-26 07:49:55 +00:00
|
|
|
errors {
|
2020-11-19 14:42:14 +00:00
|
|
|
...AttributeErrorFragment
|
2020-03-24 14:05:26 +00:00
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-28 12:45:11 +00:00
|
|
|
export const useAttributeValueCreateMutation = makeMutation<
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeValueCreate,
|
|
|
|
AttributeValueCreateVariables
|
|
|
|
>(attributeValueCreateMutation);
|
|
|
|
|
|
|
|
export const attributeCreateMutation = gql`
|
2020-11-19 14:42:14 +00:00
|
|
|
${attributeErrorFragment}
|
2019-08-09 10:17:04 +00:00
|
|
|
mutation AttributeCreate($input: AttributeCreateInput!) {
|
|
|
|
attributeCreate(input: $input) {
|
|
|
|
attribute {
|
2021-05-24 11:01:18 +00:00
|
|
|
id
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
2021-04-26 07:49:55 +00:00
|
|
|
errors {
|
2020-11-19 14:42:14 +00:00
|
|
|
...AttributeErrorFragment
|
2020-03-24 14:05:26 +00:00
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-28 12:45:11 +00:00
|
|
|
export const useAttributeCreateMutation = makeMutation<
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeCreate,
|
|
|
|
AttributeCreateVariables
|
|
|
|
>(attributeCreateMutation);
|
|
|
|
|
|
|
|
const attributeValueReorderMutation = gql`
|
2020-11-19 14:42:14 +00:00
|
|
|
${attributeErrorFragment}
|
2021-05-24 11:01:18 +00:00
|
|
|
${pageInfoFragment}
|
|
|
|
mutation AttributeValueReorder(
|
|
|
|
$id: ID!
|
|
|
|
$move: ReorderInput!
|
|
|
|
$firstValues: Int
|
|
|
|
$afterValues: String
|
|
|
|
$lastValues: Int
|
|
|
|
$beforeValues: String
|
|
|
|
) {
|
2019-08-09 10:17:04 +00:00
|
|
|
attributeReorderValues(attributeId: $id, moves: [$move]) {
|
|
|
|
attribute {
|
|
|
|
id
|
2021-06-02 19:11:30 +00:00
|
|
|
choices(
|
2021-05-24 11:01:18 +00:00
|
|
|
first: $firstValues
|
|
|
|
after: $afterValues
|
|
|
|
last: $lastValues
|
|
|
|
before: $beforeValues
|
|
|
|
) {
|
|
|
|
pageInfo {
|
|
|
|
...PageInfoFragment
|
|
|
|
}
|
|
|
|
edges {
|
|
|
|
cursor
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-26 07:49:55 +00:00
|
|
|
errors {
|
2020-11-19 14:42:14 +00:00
|
|
|
...AttributeErrorFragment
|
2020-03-24 14:05:26 +00:00
|
|
|
}
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-08-28 12:45:11 +00:00
|
|
|
export const useAttributeValueReorderMutation = makeMutation<
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeValueReorder,
|
|
|
|
AttributeValueReorderVariables
|
|
|
|
>(attributeValueReorderMutation);
|