Skip to content

Commit e199f1e

Browse files
fix(index): detect enum field (medusajs#14298)
## Summary **What** — What changes are introduced in this PR? Fixes Enum fields detection on Index module
1 parent a43eb11 commit e199f1e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/fruity-shoes-lie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/index": patch
3+
---
4+
5+
fix(index): detect enum fields

packages/modules/index/src/utils/build-config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,9 @@ function processEntity(
845845
]
846846
intermediateEntityObjectRepresentationRef.moduleConfig =
847847
intermediateEntityModule
848-
if (!intermediateEntityObjectRepresentationRef.fields.includes("id")) {
848+
if (
849+
!intermediateEntityObjectRepresentationRef.fields.includes("id")
850+
) {
849851
intermediateEntityObjectRepresentationRef.fields.push("id")
850852
}
851853

@@ -1185,7 +1187,10 @@ function buildSchemaFromFilterableLinks(
11851187
const fieldType = fieldRef.type.toString()
11861188
const isArray = fieldType.startsWith("[")
11871189
let currentType = fieldType.replace(/\[|\]|\!/g, "")
1188-
const isEnum = currentType.endsWith("Enum")
1190+
const isEnum =
1191+
fieldRef.type?.ofType?.astNode?.kind ===
1192+
GraphQLUtils.Kind.ENUM_TYPE_DEFINITION
1193+
11891194
if (isEnum) {
11901195
currentType = "String"
11911196
}

0 commit comments

Comments
 (0)