2020-07-07 10:14:12 +00:00
|
|
|
import { webhookErrorFragment } from "@saleor/fragments/errors";
|
|
|
|
import { webhooksDetailsFragment } from "@saleor/fragments/webhooks";
|
2020-07-22 10:54:15 +00:00
|
|
|
import makeMutation from "@saleor/hooks/makeMutation";
|
2019-10-09 06:01:52 +00:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
|
|
import { WebhookCreate, WebhookCreateVariables } from "./types/WebhookCreate";
|
|
|
|
import { WebhookDelete, WebhookDeleteVariables } from "./types/WebhookDelete";
|
|
|
|
import { WebhookUpdate, WebhookUpdateVariables } from "./types/WebhookUpdate";
|
|
|
|
|
|
|
|
const webhookCreate = gql`
|
|
|
|
${webhooksDetailsFragment}
|
2020-03-18 11:03:20 +00:00
|
|
|
${webhookErrorFragment}
|
2019-10-09 06:01:52 +00:00
|
|
|
mutation WebhookCreate($input: WebhookCreateInput!) {
|
2019-10-09 06:56:46 +00:00
|
|
|
webhookCreate(input: $input) {
|
2020-03-18 11:03:20 +00:00
|
|
|
errors: webhookErrors {
|
|
|
|
...WebhookErrorFragment
|
2019-10-18 12:01:26 +00:00
|
|
|
}
|
2019-10-09 06:01:52 +00:00
|
|
|
webhook {
|
|
|
|
...WebhooksDetailsFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const webhookUpdate = gql`
|
|
|
|
${webhooksDetailsFragment}
|
2020-03-18 11:03:20 +00:00
|
|
|
${webhookErrorFragment}
|
2019-10-09 06:01:52 +00:00
|
|
|
mutation WebhookUpdate($id: ID!, $input: WebhookUpdateInput!) {
|
2019-10-09 06:56:46 +00:00
|
|
|
webhookUpdate(id: $id, input: $input) {
|
2020-03-18 11:03:20 +00:00
|
|
|
errors: webhookErrors {
|
|
|
|
...WebhookErrorFragment
|
2019-10-18 12:01:26 +00:00
|
|
|
}
|
2019-10-09 06:01:52 +00:00
|
|
|
webhook {
|
|
|
|
...WebhooksDetailsFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2019-10-09 07:31:00 +00:00
|
|
|
const webhookDelete = gql`
|
2020-03-18 11:03:20 +00:00
|
|
|
${webhookErrorFragment}
|
2019-10-09 06:01:52 +00:00
|
|
|
mutation WebhookDelete($id: ID!) {
|
2019-10-09 06:56:46 +00:00
|
|
|
webhookDelete(id: $id) {
|
2020-03-18 11:03:20 +00:00
|
|
|
errors: webhookErrors {
|
|
|
|
...WebhookErrorFragment
|
2019-10-09 06:01:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2020-07-22 10:54:15 +00:00
|
|
|
|
|
|
|
export const useWebhookCreateMutation = makeMutation<
|
|
|
|
WebhookCreate,
|
|
|
|
WebhookCreateVariables
|
|
|
|
>(webhookCreate);
|
|
|
|
|
|
|
|
export const useWebhookDeleteMutation = makeMutation<
|
2019-10-09 06:01:52 +00:00
|
|
|
WebhookDelete,
|
|
|
|
WebhookDeleteVariables
|
2019-10-10 05:38:21 +00:00
|
|
|
>(webhookDelete);
|
2020-07-22 10:54:15 +00:00
|
|
|
|
|
|
|
export const useWebhookUpdateMutation = makeMutation<
|
|
|
|
WebhookUpdate,
|
|
|
|
WebhookUpdateVariables
|
|
|
|
>(webhookUpdate);
|