nestjs-temporal-core
    Preparing search index...

    Function ChildWorkflow

    • Property decorator to inject a child workflow proxy into a parent workflow. Child workflows are independent workflow executions that are started and managed by a parent workflow. This decorator creates a proxy that allows easy invocation of child workflows with proper typing.

      This decorator works in v8 isolated environments by using Temporal's startChild API without relying on dependency injection or external services. Configuration is handled dynamically at runtime through the workflow execution context.

      Parameters

      • workflowType: Type<unknown>

        The workflow class/type to create a proxy for

      • Optionaloptions: { taskQueue?: string }

      Returns PropertyDecorator

      // In function-based workflow
      export async function orderWorkflow(order: Order): Promise<OrderResult> {
      // Start child workflows using startChild from @temporalio/workflow
      const reservationHandle = await wf.startChild(inventoryWorkflow, {
      args: [order.items],
      workflowId: `inventory-${order.id}`
      });
      const reservation = await reservationHandle.result();

      const paymentHandle = await wf.startChild(paymentWorkflow, {
      args: [{ amount: order.total, customerId: order.customerId }],
      workflowId: `payment-${order.id}`
      });
      const payment = await paymentHandle.result();

      return { orderId: order.id, paymentId: payment.id };
      }
      • Child workflows are independent and can outlive the parent workflow
      • They provide better fault isolation
      • Use child workflows for operations that should continue even if parent fails
      • Configuration like task queues should be handled via module configuration, not decorator options
      • Each method call on the proxy starts a new child workflow instance