|
1
|
If you get the following error when you start the Medusa application: |
|
2
|
|
|
3
|
```bash |
|
4
|
Error: Step X is already defined in workflow. |
|
5
|
``` |
|
6
|
|
|
7
|
Where `X` is any step, such as `create-remote-link`. |
|
8
|
|
|
9
|
## Why this Error Occurred |
|
10
|
|
|
11
|
This error indicates that you're re-using a step in a workflow, meaning that more than one step in the workflow have the same name. |
|
12
|
|
|
13
|
--- |
|
14
|
|
|
15
|
## How to Fix it |
|
16
|
|
|
17
|
To resolve this error, use the `config` method of a step to specify a custom name within the workflow's scope. For example: |
|
18
|
|
|
19
|
```ts |
|
20
|
const helloWorkflow = createWorkflow( |
|
21
|
"hello", |
|
22
|
() => { |
|
23
|
const { data: products } = useQueryGraphStep({ |
|
24
|
entity: "product", |
|
25
|
fields: ["id"], |
|
26
|
}) |
|
27
|
|
|
28
|
// ✓ No error occurs, the step has a different ID. |
|
29
|
const { data: customers } = useQueryGraphStep({ |
|
30
|
entity: "customer", |
|
31
|
fields: ["id"], |
|
32
|
}).config({ name: "fetch-customers" }) |
|
33
|
} |
|
34
|
) |
|
35
|
``` |
|
36
|
|
|
37
|
In the above example, you use the `config` method on the second `useQueryGraphStep` usage to change its name to `fetch-customers`. |
|
38
|
|
|
39
|
Make sure to change the name of every usage after the first one in a workflow. |
|
40
|
|
|
41
|
--- |
|
42
|
|
|
43
|
## Additional Resources |
|
44
|
|
|
45
|
- [Multiple Step Usage in Workflow documentation](https://docs.medusajs.com/learn/fundamentals/workflows/multiple-step-usage) |