From e199f1eb01ed8e25e0864f77580e75f19412d6c5 Mon Sep 17 00:00:00 2001 From: "Carlos R. L. Rodrigues" <37986729+carlos-r-l-rodrigues@users.noreply.github.com> Date: Sat, 13 Dec 2025 17:35:07 -0300 Subject: [PATCH] fix(index): detect enum field (#14298) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary **What** — What changes are introduced in this PR? Fixes Enum fields detection on Index module --- .changeset/fruity-shoes-lie.md | 5 +++++ packages/modules/index/src/utils/build-config.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/fruity-shoes-lie.md diff --git a/.changeset/fruity-shoes-lie.md b/.changeset/fruity-shoes-lie.md new file mode 100644 index 0000000000..b6760dad98 --- /dev/null +++ b/.changeset/fruity-shoes-lie.md @@ -0,0 +1,5 @@ +--- +"@medusajs/index": patch +--- + +fix(index): detect enum fields diff --git a/packages/modules/index/src/utils/build-config.ts b/packages/modules/index/src/utils/build-config.ts index c7e1b599e1..4c3dae4db2 100644 --- a/packages/modules/index/src/utils/build-config.ts +++ b/packages/modules/index/src/utils/build-config.ts @@ -845,7 +845,9 @@ function processEntity( ] intermediateEntityObjectRepresentationRef.moduleConfig = intermediateEntityModule - if (!intermediateEntityObjectRepresentationRef.fields.includes("id")) { + if ( + !intermediateEntityObjectRepresentationRef.fields.includes("id") + ) { intermediateEntityObjectRepresentationRef.fields.push("id") } @@ -1185,7 +1187,10 @@ function buildSchemaFromFilterableLinks( const fieldType = fieldRef.type.toString() const isArray = fieldType.startsWith("[") let currentType = fieldType.replace(/\[|\]|\!/g, "") - const isEnum = currentType.endsWith("Enum") + const isEnum = + fieldRef.type?.ofType?.astNode?.kind === + GraphQLUtils.Kind.ENUM_TYPE_DEFINITION + if (isEnum) { currentType = "String" }