chore(medusa): rm default created at field (#8213)
**What** To maintain the backward compatibility, we use to populate `created_at` no matter what. But since we can break things from v1, I ll remove it as we moved the default ordering to the repository layer
This commit is contained in:
committed by
GitHub
parent
f74fdcb644
commit
c307972a99
@@ -13,7 +13,7 @@ const adminSeeder = require("../../../helpers/admin-seeder")
|
||||
const {
|
||||
allowedStoreProductsFields,
|
||||
defaultStoreProductsRelations,
|
||||
} = require("@medusajs/medusa/dist")
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
const adminHeaders = {
|
||||
headers: {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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"],
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
@@ -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<T extends RequestQueryFields, TEntity>(
|
||||
})
|
||||
}
|
||||
|
||||
// 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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user