docs: added to workflow legend + example improvements (#11895)
This commit is contained in:
@@ -13,17 +13,17 @@ Medusa wraps service method executions to inject useful context or transactions.
|
||||
For example, if you have a synchronous `getMessage` method, and you use it in other resources like workflows, Medusa executes it as an async method:
|
||||
|
||||
```ts
|
||||
await helloModuleService.getMessage()
|
||||
await blogModuleService.getMessage()
|
||||
```
|
||||
|
||||
So, make sure your service's methods are always async to avoid unexpected errors or behavior.
|
||||
|
||||
```ts highlights={[["8", "", "Method must be async."], ["13", "async", "Correct way of defining the method."]]}
|
||||
import { MedusaService } from "@medusajs/framework/utils"
|
||||
import MyCustom from "./models/my-custom"
|
||||
import Post from "./models/post"
|
||||
|
||||
class HelloModuleService extends MedusaService({
|
||||
MyCustom,
|
||||
class BlogModuleService extends MedusaService({
|
||||
Post,
|
||||
}){
|
||||
// Don't
|
||||
getMessage(): string {
|
||||
@@ -36,5 +36,5 @@ class HelloModuleService extends MedusaService({
|
||||
}
|
||||
}
|
||||
|
||||
export default HelloModuleService
|
||||
export default BlogModuleService
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user