Skip to content

Commit 39325bf

Browse files
authored
Update child-workflows.md for query method safety
Clarified important note about query methods and child handles in workflows.
1 parent 7bb019e commit 39325bf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/features/child-workflows.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,15 @@ class ParentWorkflow extends Workflow
170170
}
171171
```
172172

173-
**Important:** When using query methods in the same workflow with child handles, you must first await for the child handle to be available in order to make it replay safe.
173+
**Important:** When using query methods in the same workflow with child handles, you must first await for the child handle to be available. Query methods like `$workflow->childId()` may return `null` if you query the parent workflow before the child workflow has started.
174174

175175
Then you can interact with the child workflow directly.
176176

177177
```php
178178
$workflow = WorkflowStub::load($workflowId);
179-
$childWorkflow = WorkflowStub::load($workflow->childId());
180-
$childWorkflow->approve('approved');
179+
if ($childId = $workflow->childId()) {
180+
WorkflowStub::load($childId)->process('approved');
181+
}
181182
```
182183

183184
## Async Activities

0 commit comments

Comments
 (0)