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:
committed by
GitHub
parent
637d4cf7ef
commit
71d8a0031f
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user