|
1 | 1 | import { v } from "convex/values"; |
2 | 2 | import { workflow } from "./example"; |
3 | 3 | import { internal } from "./_generated/api"; |
| 4 | +import { internalMutation } from "./_generated/server"; |
4 | 5 |
|
5 | 6 | export const parentWorkflow = workflow.define({ |
6 | 7 | args: { prompt: v.string() }, |
7 | | - returns: v.null(), |
8 | 8 | handler: async (ctx, args) => { |
9 | 9 | console.log("Starting confirmation workflow"); |
10 | 10 | const length = await ctx.runWorkflow( |
11 | | - internal.nestedWorkflow.nestedWorkflow, |
| 11 | + internal.nestedWorkflow.childWorkflow, |
12 | 12 | { foo: args.prompt }, |
13 | 13 | ); |
14 | 14 | console.log("Length:", length); |
| 15 | + const stepResult = await ctx.runMutation(internal.nestedWorkflow.step, { |
| 16 | + foo: args.prompt, |
| 17 | + }); |
| 18 | + console.log("Step result:", stepResult); |
15 | 19 | }, |
16 | 20 | }); |
17 | 21 |
|
18 | | -export const nestedWorkflow = workflow.define({ |
| 22 | +export const childWorkflow = workflow.define({ |
19 | 23 | args: { foo: v.string() }, |
20 | 24 | returns: v.number(), |
21 | | - handler: async (_, args) => { |
| 25 | + handler: async (_ctx, args) => { |
22 | 26 | console.log("Starting nested workflow"); |
23 | 27 | return args.foo.length; |
24 | 28 | }, |
25 | 29 | }); |
| 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