saleor-dashboard/src/webhooks/mutations.ts

68 lines
1.6 KiB
TypeScript
Raw Normal View History

2019-10-09 06:01:52 +00:00
import gql from "graphql-tag";
import { TypedMutation } from "../mutations";
import { webhooksDetailsFragment } from "./queries";
import { WebhookCreate, WebhookCreateVariables } from "./types/WebhookCreate";
import { WebhookDelete, WebhookDeleteVariables } from "./types/WebhookDelete";
import { WebhookUpdate, WebhookUpdateVariables } from "./types/WebhookUpdate";
2020-03-18 11:03:20 +00:00
const webhookErrorFragment = gql`
fragment WebhookErrorFragment on WebhookError {
code
field
}
`;
2019-10-09 06:01:52 +00:00
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
}
}
}
`;
export const TypedWebhookCreate = TypedMutation<
WebhookCreate,
WebhookCreateVariables
>(webhookCreate);
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
}
}
}
`;
export const TypedWebhookUpdate = TypedMutation<
WebhookUpdate,
WebhookUpdateVariables
>(webhookUpdate);
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
}
}
}
`;
export const TypedWebhookDelete = TypedMutation<
WebhookDelete,
WebhookDeleteVariables
2019-10-10 05:38:21 +00:00
>(webhookDelete);