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: local workflow proxying methods to pass context #6263

Merged
merged 17 commits into from
Feb 1, 2024

Conversation

carlos-r-l-rodrigues
Copy link
Contributor

@carlos-r-l-rodrigues carlos-r-l-rodrigues commented Jan 29, 2024

What:

  • When calling a module's method inside a Local Workflow the MedusaContext is passed as the last argument to the method if not provided
  • Add requestId to req
  • A couple of fixes on Remote Joiner and the data fetcher for internal services

Why:

  • The context used to initialize the workflow has to be shared with all modules. properties like transactionId will be used to emit events and requestId to trace logs for example.

Copy link

changeset-bot bot commented Jan 29, 2024

🦋 Changeset detected

Latest commit: ff4eec1

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

This PR includes changesets to release 11 packages
Name Type
@medusajs/stock-location Patch
@medusajs/orchestration Patch
@medusajs/workflows-sdk Patch
@medusajs/link-modules Patch
@medusajs/modules-sdk Patch
@medusajs/inventory Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/medusa Patch
@medusajs/types Patch
@medusajs/utils 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 Jan 29, 2024

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 1, 2024 1:15pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Feb 1, 2024 1:15pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 1:15pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 1:15pm

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.

Just to be sure, this means these two code snippets are functionally identical right?

Explicit context:

createStep("some-step", (input, { container, context }) => {
  const moduleService = container.resolve("someModule")
  await moduleService.create(data, context)
})

Magical context

createStep("some-step", (input, { container }) => {
  const moduleService = container.resolve("someModule")
  await moduleService.create(data)
})

In the latter case, the context is passed (under the hood/magically) as if we were doing it explicitly.

this.container = this.contextualizedMedusaModules(container)
}

private contextualizedMedusaModules(container) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to have @adrien2p's eye on this one

@carlos-r-l-rodrigues
Copy link
Contributor Author

Just to be sure, this means these two code snippets are functionally identical right?

That is correct.

@olivermrbl
Copy link
Contributor

Should we merge this one?

@carlos-r-l-rodrigues
Copy link
Contributor Author

Should we merge this one?

I think so.
@adrien2p?

@adrien2p
Copy link
Member

adrien2p commented Feb 1, 2024

I would say yes 🙏

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