saleor-dashboard/src/webhooks/queries.ts

101 lines
2 KiB
TypeScript
Raw Normal View History

2019-10-09 06:01:52 +00:00
import gql from "graphql-tag";
import { TypedQuery } from "../queries";
2019-10-09 20:50:03 +00:00
import { ServiceList, ServiceListVariables } from "./types/ServiceList";
2019-10-09 06:01:52 +00:00
import { Webhook, WebhookVariables } from "./types/Webhook";
import { Webhooks, WebhooksVariables } from "./types/Webhooks";
2019-10-09 20:50:03 +00:00
export const serviceFragment = gql`
fragment ServiceFragment on ServiceAccount {
id
name
isActive
}
`;
2019-10-09 06:01:52 +00:00
export const webhooksFragment = gql`
fragment WebhookFragment on Webhook {
id
2019-10-09 06:56:46 +00:00
name
2019-10-09 06:01:52 +00:00
events {
eventType
}
isActive
secretKey
targetUrl
serviceAccount {
id
name
}
}
`;
export const webhooksDetailsFragment = gql`
${webhooksFragment}
fragment WebhooksDetailsFragment on Webhook {
2019-10-09 06:56:46 +00:00
...WebhookFragment
2019-10-09 06:01:52 +00:00
}
`;
const webhooksList = gql`
${webhooksFragment}
query Webhooks($first: Int, $after: String, $last: Int, $before: String) {
webhooks(before: $before, after: $after, first: $first, last: $last) {
edges {
node {
2019-10-09 06:56:46 +00:00
...WebhookFragment
2019-10-09 06:01:52 +00:00
}
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
}
}
`;
export const TypedWebhooksListQuery = TypedQuery<Webhooks, WebhooksVariables>(
webhooksList
);
2019-10-09 20:50:03 +00:00
const serviceList = gql`
${serviceFragment}
query ServiceList($first: Int, $after: String, $last: Int, $before: String) {
serviceAccounts(
first: $first
after: $after
before: $before
last: $last
) {
edges {
node {
...ServiceFragment
}
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
}
}
`;
export const TypedServiceListQuery = TypedQuery<
ServiceList,
ServiceListVariables
>(serviceList);
2019-10-09 06:01:52 +00:00
const webhooksDetails = gql`
${webhooksFragment}
query Webhook($id: ID!) {
webhook(id: $id) {
2019-10-09 06:56:46 +00:00
...WebhookFragment
2019-10-09 06:01:52 +00:00
}
}
`;
export const TypedWebhooksDetailsQuery = TypedQuery<Webhook, WebhookVariables>(
webhooksDetails
);