Skip to content

Commit 4a34800

Browse files
committed
add step to example
1 parent bdf2e71 commit 4a34800

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

example/convex/nestedWorkflow.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
import { v } from "convex/values";
22
import { workflow } from "./example";
33
import { internal } from "./_generated/api";
4+
import { internalMutation } from "./_generated/server";
45

56
export const parentWorkflow = workflow.define({
67
args: { prompt: v.string() },
7-
returns: v.null(),
88
handler: async (ctx, args) => {
99
console.log("Starting confirmation workflow");
1010
const length = await ctx.runWorkflow(
11-
internal.nestedWorkflow.nestedWorkflow,
11+
internal.nestedWorkflow.childWorkflow,
1212
{ foo: args.prompt },
1313
);
1414
console.log("Length:", length);
15+
const stepResult = await ctx.runMutation(internal.nestedWorkflow.step, {
16+
foo: args.prompt,
17+
});
18+
console.log("Step result:", stepResult);
1519
},
1620
});
1721

18-
export const nestedWorkflow = workflow.define({
22+
export const childWorkflow = workflow.define({
1923
args: { foo: v.string() },
2024
returns: v.number(),
21-
handler: async (_, args) => {
25+
handler: async (_ctx, args) => {
2226
console.log("Starting nested workflow");
2327
return args.foo.length;
2428
},
2529
});
30+
31+
export const step = internalMutation({
32+
args: { foo: v.string() },
33+
handler: async (_ctx, args) => {
34+
console.log("Starting step");
35+
return args.foo.length;
36+
},
37+
});

0 commit comments

Comments
 (0)