const CREATE_WORKFLOW = gql`
mutation CreateWorkflow($input: CreateWorkflowInput!) {
createWorkflow(input: $input) {
id
name
active
filterRule
data
dataTypeSlug
createdAt
createdBy
workflowSignals {
id
eventName
start
}
}
}
`;
const { data } = await client.mutate({
mutation: CREATE_WORKFLOW,
variables: {
input: {
name: "Inventory Restock Workflow",
active: true,
filterRule: "item.quantity < item.minimum_stock",
data: {
description: "Automatically triggers when inventory falls below minimum stock",
priority: "high",
department: "inventory_management",
notification_channels: ["email", "slack"],
escalation_rules: {
after_hours: 2,
business_hours: 4
}
},
dataTypeSlug: "inventory_workflow",
workflowsignalIDs: ["signal_123", "signal_456"]
}
}
});
console.log(`Created workflow: ${data.createWorkflow.name} with ID: ${data.createWorkflow.id}`);