Looking at the TypeScript examples, workflows are returning unstructured message strings, usually returned by activities. For example, in nextjs-ecommerce-oneclick:
Also don’t see how these values are accessed or used on the client side. For example, in the above example, the return value is not accessed or used.
What are the best practices around determining the return value from a workflow?
Would it be a good pattern to at least return the current workflow state so that the client can enable the next set of valid actions. Currently my client is using await workflow.query('workflowState') to get the current state, but that seems like an unnecessary round trip. Of course, I realize that the workflow state can change anytime, but this approach might cover some use cases without a round trip.
How does the client access the return value (in TypeScript)?
What are the best practices around determining the return value from a workflow?
I think this is closely related to your business. What do you need your workflow function to return?
Would it be a good pattern to at least return the current workflow state so that the client can enable the next set of valid actions. Currently my client is using await workflow.query('workflowState') to get the current state, but that seems like an unnecessary round trip. Of course, I realize that the workflow state can change anytime, but this approach might cover some use cases without a round trip.
Just in case it helps, with handle.describe() you can get other useful information, like the workflow status (completed, running…) : await handle.describe()).status
In many use cases, a result of the workflow should be pushed to some external system. In this case, you can use an activity that executes at the end of the workflow and sends the result.