fix: custom link resolution in medusa app (#7950)

* fix custom link resolution in medusa app

* improve

* fix duplicate
This commit is contained in:
Adrien de Peretti authored and GitHub committed 2024-07-04 16:50:53 +02:00
1 parent 5544303b91
commit f49139b20f
3 files changed
+16 -12

No files matched your search

+2 -8
View File
@@ -435,12 +435,6 @@ async function MedusaApp_({
...(sharedResourcesConfig?.database ?? {}),
}
const customLinks = MedusaModule.getCustomLinks().map((link) => {
return typeof link === "function"
? link(MedusaModule.getAllJoinerConfigs())
: link
})
if (revert) {
revertLinkModuleMigration &&
(await revertLinkModuleMigration(
@@ -448,7 +442,7 @@ async function MedusaApp_({
options: linkModuleOpt,
injectedDependencies,
},
customLinks
linkModules
))
} else {
linkModuleMigration &&
@@ -457,7 +451,7 @@ async function MedusaApp_({
options: linkModuleOpt,
injectedDependencies,
},
customLinks
linkModules
))
}
}
@@ -2,6 +2,8 @@ import { LinkModulesExtraFields, ModuleJoinerConfig } from "@medusajs/types"
import { isObject, pluralize, toPascalCase } from "../common"
import { composeLinkName } from "../link"
export const DefineLinkSymbol = Symbol.for("DefineLink")
type InputSource = {
serviceName: string
field: string
@@ -116,7 +118,7 @@ export function defineLink(
throw new Error(`Invalid linkable passed for the second argument`)
}
const output = { serviceName: "" }
const output = { [DefineLinkSymbol]: true, serviceName: "" }
const register = function (
modules: ModuleJoinerConfig[]