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