Skip to content

Commit

Permalink
fix(medusa): Use query relation load strategy on Products (medusajs#3926
Browse files Browse the repository at this point in the history
)

* fix(medusa): products retrieve uses query strategy for performance

* chore: packaged version of medusa typeorm fix

* chore: update path

* chore: stock locations uses typeorm version

* chore: resolve typeorm to medusa package

* chore: Update medusa project in CI action

* chore: temp disable transaction timeout for plugins

---------

Co-authored-by: Oliver Windall Juhl <[email protected]>
Co-authored-by: olivermrbl <[email protected]>
  • Loading branch information
3 people authored May 2, 2023
1 parent c04cbba commit 4e8045a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-tips-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

fix(medusa): products retrieve uses query strategy for performance
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const {
simpleShippingOptionFactory,
} = require("../../../factories")

jest.setTimeout(50000)
jest.setTimeout(150000)

const adminHeaders = { headers: { Authorization: "Bearer test_token" } }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { setPort, useApi } = require("../../../helpers/use-api")

const adminSeeder = require("../../helpers/admin-seeder")

jest.setTimeout(50000)
jest.setTimeout(10000)

const {
simpleOrderFactory,
Expand Down
1 change: 1 addition & 0 deletions integration-tests/plugins/medusa-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
database_type: "postgres",
jwt_secret: "test",
cookie_secret: "test",
database_extra: { idle_in_transaction_session_timeout: 0 }
},
modules: {
stockLocationService: {
Expand Down
5 changes: 4 additions & 1 deletion packages/medusa/src/repositories/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export const ProductRepository = dataSource.getRepository(Product).extend({
async findOne(
options: ExtendedFindConfig<Product & ProductFilterOptions>
): Promise<Product | null> {
const queryBuilder = await this.prepareQueryBuilder_(options)
const options_ = { ...options }
options_.relationLoadStrategy = "query"

const queryBuilder = await this.prepareQueryBuilder_(options_)
return await queryBuilder.getOne()
},

Expand Down

0 comments on commit 4e8045a

Please sign in to comment.