2020-07-07 10:14:12 +00:00
|
|
|
import { pageErrorFragment } from "@saleor/fragments/errors";
|
|
|
|
import { pageDetailsFragment } from "@saleor/fragments/pages";
|
2019-06-19 14:40:52 +00:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
|
|
import { TypedMutation } from "../mutations";
|
|
|
|
import {
|
|
|
|
PageBulkPublish,
|
|
|
|
PageBulkPublishVariables
|
|
|
|
} from "./types/PageBulkPublish";
|
|
|
|
import {
|
|
|
|
PageBulkRemove,
|
|
|
|
PageBulkRemoveVariables
|
|
|
|
} from "./types/PageBulkRemove";
|
|
|
|
import { PageCreate, PageCreateVariables } from "./types/PageCreate";
|
|
|
|
import { PageRemove, PageRemoveVariables } from "./types/PageRemove";
|
|
|
|
import { PageUpdate, PageUpdateVariables } from "./types/PageUpdate";
|
|
|
|
|
|
|
|
const pageCreate = gql`
|
|
|
|
${pageDetailsFragment}
|
2020-03-17 10:57:02 +00:00
|
|
|
${pageErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation PageCreate($input: PageInput!) {
|
|
|
|
pageCreate(input: $input) {
|
2020-03-17 10:57:02 +00:00
|
|
|
errors: pageErrors {
|
|
|
|
...PageErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
page {
|
|
|
|
...PageDetailsFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedPageCreate = TypedMutation<PageCreate, PageCreateVariables>(
|
|
|
|
pageCreate
|
|
|
|
);
|
|
|
|
|
|
|
|
const pageUpdate = gql`
|
|
|
|
${pageDetailsFragment}
|
2020-03-17 10:57:02 +00:00
|
|
|
${pageErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation PageUpdate($id: ID!, $input: PageInput!) {
|
|
|
|
pageUpdate(id: $id, input: $input) {
|
2020-03-17 10:57:02 +00:00
|
|
|
errors: pageErrors {
|
|
|
|
...PageErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
page {
|
|
|
|
...PageDetailsFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedPageUpdate = TypedMutation<PageUpdate, PageUpdateVariables>(
|
|
|
|
pageUpdate
|
|
|
|
);
|
|
|
|
|
|
|
|
const pageRemove = gql`
|
2020-03-17 10:57:02 +00:00
|
|
|
${pageErrorFragment}
|
2019-06-19 14:40:52 +00:00
|
|
|
mutation PageRemove($id: ID!) {
|
|
|
|
pageDelete(id: $id) {
|
2020-03-17 10:57:02 +00:00
|
|
|
errors: pageErrors {
|
|
|
|
...PageErrorFragment
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedPageRemove = TypedMutation<PageRemove, PageRemoveVariables>(
|
|
|
|
pageRemove
|
|
|
|
);
|
|
|
|
|
|
|
|
const pageBulkPublish = gql`
|
|
|
|
mutation PageBulkPublish($ids: [ID]!, $isPublished: Boolean!) {
|
|
|
|
pageBulkPublish(ids: $ids, isPublished: $isPublished) {
|
|
|
|
errors {
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedPageBulkPublish = TypedMutation<
|
|
|
|
PageBulkPublish,
|
|
|
|
PageBulkPublishVariables
|
|
|
|
>(pageBulkPublish);
|
|
|
|
|
|
|
|
const pageBulkRemove = gql`
|
|
|
|
mutation PageBulkRemove($ids: [ID]!) {
|
|
|
|
pageBulkDelete(ids: $ids) {
|
|
|
|
errors {
|
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const TypedPageBulkRemove = TypedMutation<
|
|
|
|
PageBulkRemove,
|
|
|
|
PageBulkRemoveVariables
|
|
|
|
>(pageBulkRemove);
|