From e3c3946acd369e7a9b2be6ec7fbfb9ad876b9e1c Mon Sep 17 00:00:00 2001 From: Duncan Mackenzie Date: Mon, 5 Oct 2026 11:35:59 -0700 Subject: [PATCH] Add typescript-start-workflow snippet for the docs Task Queue section docs.temporal.io's TypeScript "Set a Workflow's Task Queue" section used a hand-written sample that called Connection.create(), which doesn't exist (temporalio/documentation#5200). This snippet replaces it with compiled code. --- snippets/src/start-workflow.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 snippets/src/start-workflow.ts diff --git a/snippets/src/start-workflow.ts b/snippets/src/start-workflow.ts new file mode 100644 index 000000000..55f2a8536 --- /dev/null +++ b/snippets/src/start-workflow.ts @@ -0,0 +1,25 @@ +// @@@SNIPSTART typescript-start-workflow +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; +import { nanoid } from 'nanoid'; +import { example } from './workflows'; + +async function run() { + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); + + const handle = await client.workflow.start(example, { + // required + taskQueue: 'snippets', + // required + workflowId: 'workflow-' + nanoid(), + }); + console.log(`Started Workflow ${handle.workflowId}`); +} +// @@@SNIPEND + +run().catch((err) => { + console.error(err); + process.exit(1); +});