-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathnestedWorkflow.ts
More file actions
37 lines (34 loc) · 1.03 KB
/
nestedWorkflow.ts
File metadata and controls
37 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { v } from "convex/values";
import { workflow } from "./example";
import { internal } from "./_generated/api";
import { internalMutation } from "./_generated/server";
export const parentWorkflow = workflow.define({
args: { prompt: v.string() },
handler: async (step, args) => {
console.log("Starting confirmation workflow");
const length = await step.runWorkflow(
internal.nestedWorkflow.childWorkflow,
{ foo: args.prompt },
);
console.log("Length:", length);
const stepResult = await step.runMutation(internal.nestedWorkflow.step, {
foo: args.prompt,
});
console.log("Step result:", stepResult);
},
});
export const childWorkflow = workflow.define({
args: { foo: v.string() },
returns: v.number(),
handler: async (_step, args) => {
console.log("Starting nested workflow");
return args.foo.length;
},
});
export const step = internalMutation({
args: { foo: v.string() },
handler: async (_ctx, args) => {
console.log("Starting step");
return args.foo.length;
},
});