feat(modules-sdk): define link (#7743)
This commit is contained in:
committed by
GitHub
parent
0886869148
commit
bc0c65c6b3
@@ -1,4 +1,3 @@
|
||||
import type { Knex } from "knex"
|
||||
import { mergeTypeDefs } from "@graphql-tools/merge"
|
||||
import { makeExecutableSchema } from "@graphql-tools/schema"
|
||||
import { RemoteFetchDataCallback } from "@medusajs/orchestration"
|
||||
@@ -26,12 +25,13 @@ import {
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import { asValue } from "awilix"
|
||||
import type { Knex } from "knex"
|
||||
import {
|
||||
MODULE_PACKAGE_NAMES,
|
||||
ModuleRegistrationName,
|
||||
Modules,
|
||||
} from "./definitions"
|
||||
import { MedusaModule } from "./medusa-module"
|
||||
import { MedusaModule, RegisterModuleJoinerConfig } from "./medusa-module"
|
||||
import { RemoteLink } from "./remote-link"
|
||||
import { RemoteQuery } from "./remote-query"
|
||||
import { MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
||||
@@ -240,7 +240,7 @@ export type MedusaAppOptions = {
|
||||
modulesConfigPath?: string
|
||||
modulesConfigFileName?: string
|
||||
modulesConfig?: MedusaModuleConfig
|
||||
linkModules?: ModuleJoinerConfig | ModuleJoinerConfig[]
|
||||
linkModules?: RegisterModuleJoinerConfig | RegisterModuleJoinerConfig[]
|
||||
remoteFetchData?: RemoteFetchDataCallback
|
||||
injectedDependencies?: any
|
||||
onApplicationStartCb?: () => void
|
||||
@@ -260,7 +260,6 @@ async function MedusaApp_({
|
||||
linkModules,
|
||||
remoteFetchData,
|
||||
injectedDependencies = {},
|
||||
onApplicationStartCb,
|
||||
migrationOnly = false,
|
||||
loaderOnly = false,
|
||||
workerMode = "server",
|
||||
@@ -363,6 +362,20 @@ async function MedusaApp_({
|
||||
allowUnregistered: true,
|
||||
})
|
||||
|
||||
linkModules ??= []
|
||||
if (!Array.isArray(linkModules)) {
|
||||
linkModules = [linkModules]
|
||||
}
|
||||
linkModules.push(...MedusaModule.getCustomLinks())
|
||||
|
||||
const allLoadedJoinerConfigs = MedusaModule.getAllJoinerConfigs()
|
||||
for (let linkIdx = 0; linkIdx < linkModules.length; linkIdx++) {
|
||||
const customLink: any = linkModules[linkIdx]
|
||||
if (typeof customLink === "function") {
|
||||
linkModules[linkIdx] = customLink(allLoadedJoinerConfigs)
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
remoteLink,
|
||||
runMigrations: linkModuleMigration,
|
||||
|
||||
Reference in New Issue
Block a user