chore: default isQueryable module (#8192)
* chore: default isQueryable module * fix defaults * fix
This commit is contained in:
committed by
GitHub
parent
4ef268d829
commit
ecc97076b5
@@ -42,6 +42,7 @@ export const ModulesDefinition: {
|
||||
defaultPackage: MODULE_PACKAGE_NAMES[Modules.EVENT_BUS],
|
||||
label: upperCaseFirst(ModuleRegistrationName.EVENT_BUS),
|
||||
isRequired: true,
|
||||
isQueryable: false,
|
||||
dependencies: ["logger"],
|
||||
defaultModuleDeclaration: {
|
||||
scope: MODULE_SCOPE.INTERNAL,
|
||||
@@ -80,6 +81,7 @@ export const ModulesDefinition: {
|
||||
defaultPackage: MODULE_PACKAGE_NAMES[Modules.CACHE],
|
||||
label: upperCaseFirst(ModuleRegistrationName.CACHE),
|
||||
isRequired: true,
|
||||
isQueryable: false,
|
||||
defaultModuleDeclaration: {
|
||||
scope: MODULE_SCOPE.INTERNAL,
|
||||
resources: MODULE_RESOURCE_TYPE.SHARED,
|
||||
|
||||
@@ -387,9 +387,19 @@ class MedusaModule {
|
||||
services[keyName].__definition = resolution.definition
|
||||
|
||||
if (resolution.definition.isQueryable) {
|
||||
const joinerConfig: ModuleJoinerConfig = await services[
|
||||
keyName
|
||||
].__joinerConfig()
|
||||
let joinerConfig!: ModuleJoinerConfig
|
||||
|
||||
try {
|
||||
joinerConfig = await services[keyName].__joinerConfig?.()
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
|
||||
if (!joinerConfig) {
|
||||
throw new Error(
|
||||
`Your module is missing a joiner config: ${keyName}. If this module is not queryable, please set { definition: { isQueryable: false } } in your module configuration.`
|
||||
)
|
||||
}
|
||||
|
||||
if (!joinerConfig.primaryKeys) {
|
||||
logger_.warn(
|
||||
@@ -513,9 +523,19 @@ class MedusaModule {
|
||||
services[keyName].__definition = resolution.definition
|
||||
|
||||
if (resolution.definition.isQueryable) {
|
||||
const joinerConfig: ModuleJoinerConfig = await services[
|
||||
keyName
|
||||
].__joinerConfig()
|
||||
let joinerConfig!: ModuleJoinerConfig
|
||||
|
||||
try {
|
||||
joinerConfig = await services[keyName].__joinerConfig?.()
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
|
||||
if (!joinerConfig) {
|
||||
throw new Error(
|
||||
`Your module is missing a joiner config: ${keyName}. If this module is not queryable, please set { definition: { isQueryable: false } } in your module configuration.`
|
||||
)
|
||||
}
|
||||
|
||||
services[keyName].__joinerConfig = joinerConfig
|
||||
MedusaModule.setJoinerConfig(keyName, joinerConfig)
|
||||
|
||||
Reference in New Issue
Block a user