Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(product): revamp upsertWithReplace and Remove its usage from product creation #11585

Merged
merged 10 commits into from
Feb 26, 2025

Conversation

adrien2p
Copy link
Member

@adrien2p adrien2p commented Feb 24, 2025

What

  • Move create product to use native create by structuring the data appropriately, it means no more upsertWithReplace being very poorly performant and got 20x better performances on staging
  • Improvements in upsertWithReplace to still get performance boost for places that still relies on it. Mostly bulking the operations when possible

Copy link

changeset-bot bot commented Feb 24, 2025

🦋 Changeset detected

Latest commit: 9366028

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 65 packages
Name Type
@medusajs/product Patch
@medusajs/utils Patch
integration-tests-http Patch
@medusajs/cli Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/promotion Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/core-flows Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/types Patch
@medusajs/workflows-sdk Patch
@medusajs/medusa-oas-cli Patch
@medusajs/oas-github-ci Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Feb 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 9:33am
7 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Feb 26, 2025 9:33am
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 9:33am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 9:33am
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 9:33am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 9:33am
resources-docs ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 9:33am
user-guide ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 9:33am

@adrien2p
Copy link
Member Author

/snapshot-this

@carlos-r-l-rodrigues
Copy link
Contributor

/snapshot-this

@adrien2p
Copy link
Member Author

/snapshot-this

@adrien2p adrien2p marked this pull request as ready for review February 25, 2025 11:46
@adrien2p adrien2p requested a review from a team as a code owner February 25, 2025 11:46
@adrien2p
Copy link
Member Author

/snapshot-this

Copy link
Contributor

🚀 A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: 75da151

@adrien2p adrien2p changed the title chore(product): Remove upsertWithReplace where needed chore(product): revamp upsertWithReplace and Remove its usage from product creation Feb 25, 2025
@medusajs medusajs deleted a comment from github-actions bot Feb 25, 2025
@medusajs medusajs deleted a comment from github-actions bot Feb 25, 2025
Comment on lines +1631 to +1633
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Tag with id ${tag.id} not found. Please create the tag before associating it with the product.`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Was this not possible previous?

Copy link
Member Author

@adrien2p adrien2p Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in an uncrontrolled way, the api only allows tag_ids and the normalisation takes the tag ids and assign them on tags in the current implementation

Copy link
Member Author

@adrien2p adrien2p Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want we could add the support for it properly in a controlled manner.

Note: it would create a change in the front facing api though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not too much work, I'd prefer that to avoid a theoretical breaking change (even though it might not affect many)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They would have had a typescript error if they were passing tags instead of tag ids, so unless they ignore the error they wouldn't have been able to pass the build

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per internal discussion, let's keep it as is, as this is more a correction of an inconstency.

Copy link
Contributor

kodiakhq bot commented Feb 26, 2025

This PR currently has a merge conflict. Please resolve this and then re-add the automerge label.

@kodiakhq kodiakhq bot merged commit eeebb35 into develop Feb 26, 2025
24 checks passed
@kodiakhq kodiakhq bot deleted the chore/upsert-with-replace-removal branch February 26, 2025 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants