fix(index): index enum fields (#13428)

https://github.com/medusajs/medusa/issues/13372

What:
 - It handles enum fields corretly when added to filterable fields
This commit is contained in:
Carlos R. L. Rodrigues
2025-09-07 10:39:58 -03:00
committed by GitHub
parent 637d4cf7ef
commit 71d8a0031f
6 changed files with 57 additions and 6 deletions

View File

@@ -1180,11 +1180,13 @@ function buildSchemaFromFilterableLinks(
return
}
const isEnum =
fieldRef.type?.astNode?.kind === GraphQLUtils.Kind.ENUM_TYPE_DEFINITION
const fieldType = isEnum ? "String" : fieldRef.type.toString()
const fieldType = fieldRef.type.toString()
const isArray = fieldType.startsWith("[")
const currentType = fieldType.replace(/\[|\]|\!/g, "")
let currentType = fieldType.replace(/\[|\]|\!/g, "")
const isEnum = currentType.endsWith("Enum")
if (isEnum) {
currentType = "String"
}
return isArray ? `[${currentType}]` : currentType
}