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 authored and GitHub committed 2025-09-07 13:39:58 +00:00
1 parent 637d4cf7ef
commit 71d8a0031f
6 files changed
+57 -6

No files matched your search

@@ -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
}