chore: default isQueryable module (#8192)

* chore: default isQueryable module

* fix defaults

* fix
This commit is contained in:
Adrien de Peretti
2024-07-19 16:14:42 +02:00
committed by GitHub
parent 4ef268d829
commit ecc97076b5
3 changed files with 38 additions and 10 deletions
+26 -6
View File
@@ -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)