diff --git a/src/workflow/runtime/WorkflowContext.ts b/src/workflow/runtime/WorkflowContext.ts index 240a1d64..908f8ef9 100644 --- a/src/workflow/runtime/WorkflowContext.ts +++ b/src/workflow/runtime/WorkflowContext.ts @@ -96,6 +96,7 @@ export default class WorkflowContext { } /** + * Deprecated, use callChildWorkflow * Schedule sub-orchestrator function for execution. * * @param orchestrator A reference to the orchestrator function call @@ -115,6 +116,26 @@ export default class WorkflowContext { return this._innerContext.callSubOrchestrator(getFunctionName(orchestrator), input, instanceId); } + /** + * Schedule child workflow for execution. + * + * @param orchestrator A reference to the orchestrator function call + * @param input The JSON-serializable input value for the orchestrator function. + * @param instanceId A unique ID to use for the sub-orchestration instance. If not provided, a new GUID will be used. + * + * @returns {Task} A Durable Task that completes when the sub-orchestrator function completes. + */ + public callChildWorkflow( + orchestrator: TWorkflow | string, + input?: TInput, + instanceId?: string, + ): Task { + if (typeof orchestrator === "string") { + return this._innerContext.callSubOrchestrator(orchestrator, input, instanceId); + } + return this._innerContext.callSubOrchestrator(getFunctionName(orchestrator), input, instanceId); + } + /** * Wait for an event to be raised with the name "name" * diff --git a/test/e2e/workflow/workflow.test.ts b/test/e2e/workflow/workflow.test.ts index 373a0cbe..5657c3a4 100644 --- a/test/e2e/workflow/workflow.test.ts +++ b/test/e2e/workflow/workflow.test.ts @@ -139,7 +139,7 @@ describe("Workflow", () => { const parentWorkflow: TWorkflow = async function* (ctx: WorkflowContext): any { // Call sub-orchestration - yield ctx.callSubWorkflow(childWorkflow); + yield ctx.callChildWorkflow(childWorkflow); }; workflowRuntime