fix(orchestrator): inject only if it has decorator (#6666)
This commit is contained in:
1 parent
d48c076b77
commit
a8794d48de
2 files changed
+9
-4
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/orchestration": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Inject context only if method use decorator @MedusaContext
|
||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
MedusaContextType,
|
MedusaContextType,
|
||||||
MedusaModuleType,
|
MedusaModuleType,
|
||||||
createMedusaContainer,
|
createMedusaContainer,
|
||||||
|
isDefined,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { asValue } from "awilix"
|
import { asValue } from "awilix"
|
||||||
import {
|
import {
|
||||||
@@ -90,11 +91,10 @@ export class LocalWorkflow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return async (...args) => {
|
return async (...args) => {
|
||||||
const ctxIndex =
|
const ctxIndex = MedusaContext.getIndex(target, prop as string)
|
||||||
MedusaContext.getIndex(target, prop as string) ?? args.length - 1
|
|
||||||
|
|
||||||
const hasContext = args[ctxIndex]?.__type === MedusaContextType
|
const hasContext = args[ctxIndex!]?.__type === MedusaContextType
|
||||||
if (!hasContext) {
|
if (!hasContext && isDefined(ctxIndex)) {
|
||||||
const context = this_.medusaContext
|
const context = this_.medusaContext
|
||||||
if (context?.__type === MedusaContextType) {
|
if (context?.__type === MedusaContextType) {
|
||||||
delete context?.manager
|
delete context?.manager
|
||||||
|
|||||||
Reference in new issue
Block a user