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

feat(workflows):product handlers should be reusable in different context #4703

Merged
merged 10 commits into from
Aug 7, 2023

Conversation

adrien2p
Copy link
Member

@adrien2p adrien2p commented Aug 7, 2023

What
The listProducts handler should not be specific to the workflow.
Same for the product removal, shouldn't expect an entire DTO but just a collection of object that at least contains the id.
Same principle applied to other product handlers

@changeset-bot
Copy link

changeset-bot bot commented Aug 7, 2023

🦋 Changeset detected

Latest commit: fb70692

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

This PR includes changesets to release 1 package
Name Type
@medusajs/workflows 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

@vercel
Copy link

vercel bot commented Aug 7, 2023

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

Name Status Preview Comments Updated (UTC)
medusa-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2023 4:13pm

@adrien2p adrien2p marked this pull request as ready for review August 7, 2023 10:06
@adrien2p adrien2p requested a review from a team as a code owner August 7, 2023 10:06
Copy link
Contributor

@riqwan riqwan left a comment

Choose a reason for hiding this comment

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

lgtm! 🔥

@adrien2p adrien2p changed the title feat(workflows): list product should be reusable in different context feat(workflows):product handlers should be reusable in different context Aug 7, 2023
Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

Should we move type PartialProduct = { handle: ProductHandle; id: string } to a type-file for reusability?

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -1,17 +1,20 @@
import { ProductTypes, WorkflowTypes } from "@medusajs/types"
import { WorkflowArguments } from "../../helper"

type HandlerInput = {
productIds: string[]
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: ids should be fine, the handler name speaks for itself

Suggested change
productIds: string[]
ids: string[]

@adrien2p
Copy link
Member Author

adrien2p commented Aug 7, 2023

Should we move type PartialProduct = { handle: ProductHandle; id: string } to a type-file for reusability?

I didn't because it is the handler typing, so if the handler needs to evolve and we are having a shared type, we will quickly end up composing custom stuff on top of it. I prefer if it stays to the handler as is for now. wdyt?

@olivermrbl
Copy link
Contributor

I prefer if it stays to the handler as is for now. wdyt?

Makes sense. Let's keep it as is 👍

@kodiakhq kodiakhq bot merged commit 8ae31af into develop Aug 7, 2023
@kodiakhq kodiakhq bot deleted the feat/create-product-workflow-list-products branch August 7, 2023 16:22
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