diff --git a/integration-tests/api/__tests__/store/products.js b/integration-tests/api/__tests__/store/products.js index c0e5d5428a..28e0dde4f7 100644 --- a/integration-tests/api/__tests__/store/products.js +++ b/integration-tests/api/__tests__/store/products.js @@ -13,7 +13,7 @@ const adminSeeder = require("../../../helpers/admin-seeder") const { allowedStoreProductsFields, defaultStoreProductsRelations, -} = require("@medusajs/medusa/dist") +} = require("@medusajs/medusa") const adminHeaders = { headers: { diff --git a/integration-tests/http/__tests__/product/store/product.spec.ts b/integration-tests/http/__tests__/product/store/product.spec.ts index e667ee605a..0f7cd18f3c 100644 --- a/integration-tests/http/__tests__/product/store/product.spec.ts +++ b/integration-tests/http/__tests__/product/store/product.spec.ts @@ -706,15 +706,10 @@ medusaIntegrationTestRunner({ // TODO: This doesn't work currently, but worked in v1 it.skip("returns a list of ordered products by variants prices ASC", async () => {}) - // BREAKING: It seems `id` and `created_at` is always returned, even if not in the fields params it("products contain only fields defined with `fields` param", async () => { const response = await api.get("/store/products?fields=handle") expect(response.status).toEqual(200) - expect(Object.keys(response.data.products[0])).toEqual([ - "handle", - "created_at", - "id", - ]) + expect(Object.keys(response.data.products[0])).toEqual(["handle", "id"]) }) it("returns a list of products in collection", async () => { diff --git a/packages/medusa/src/api/utils/__tests__/validate-query.spec.ts b/packages/medusa/src/api/utils/__tests__/validate-query.spec.ts index 854c8750ba..815e087aa8 100644 --- a/packages/medusa/src/api/utils/__tests__/validate-query.spec.ts +++ b/packages/medusa/src/api/utils/__tests__/validate-query.spec.ts @@ -195,7 +195,7 @@ describe("validateAndTransformQuery", () => { expect(mockRequest.listConfig).toEqual( expect.objectContaining({ - select: ["id", "created_at"], + select: ["id"], }) ) @@ -406,13 +406,13 @@ describe("validateAndTransformQuery", () => { expect(mockRequest.listConfig).toEqual( expect.objectContaining({ - select: ["store.name", "created_at", "id"], + select: ["store.name", "id"], relations: ["store"], }) ) expect(mockRequest.remoteQueryConfig).toEqual( expect.objectContaining({ - fields: ["store.name", "created_at", "id"], + fields: ["store.name", "id"], }) ) }) diff --git a/packages/medusa/src/utils/get-query-config.ts b/packages/medusa/src/utils/get-query-config.ts index 03b112a136..af387c8735 100644 --- a/packages/medusa/src/utils/get-query-config.ts +++ b/packages/medusa/src/utils/get-query-config.ts @@ -1,10 +1,11 @@ import { getSetDifference, + isDefined, isPresent, + MedusaError, stringToSelectRelationObject, } from "@medusajs/utils" import { pick } from "lodash" -import { MedusaError, isDefined } from "@medusajs/utils" import { RequestQueryFields } from "@medusajs/types" import { FindConfig, QueryConfig } from "../types/common" @@ -76,10 +77,6 @@ export function prepareListQuery( }) } - // TODO: Maintain backward compatibility, remove in future. the created at was only added in the list query for default order - if (queryConfig.isList) { - allFields.add("created_at") - } allFields.add("id") }