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(utils): defineReadOnlyLink #9459

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

carlos-r-l-rodrigues
Copy link
Contributor

What:
defineReadOnlyLink util to register read-only links

Possible ways to define a link: (These don't represent real links, it is just a reference for input shapes)

defineReadOnlyLink(
  {
    linkable: CurrencyModule.linkable.currency,
    field: "custom_currency_id",
  },
  {
    linkable: CurrencyModule.linkable.currency,
    field: "country_code",
    alias: "custom_region_code",
  }
)

defineReadOnlyLink(
  {
    linkable: CurrencyModule.linkable.currency,
    field: "my_custom_id",
  },
  {
    module: Modules.REGION,
    entity: "Country",
    field: "region_country_code_id",
    alias: "my_custom_region",
  }
)

defineReadOnlyLink(
  {
    linkable: CurrencyModule.linkable.currency,
    field: "my_custom_id",
  },
  {
    module: Modules.REGION,
    entity: "Country",
    field: "region_country_code_id",
    alias: "my_custom_region",
  }
)

defineReadOnlyLink(
  {
    module: Modules.REGION,
    entity: "Country",
    field: "country_code",
  },
  {
    module: "Weather",
    field: "country_code_id",
    alias: "weather_forecast",
    isList: true,
  }
)

defineReadOnlyLink(
  {
    module: Modules.PRODUCT,
    field: "season_id",
  },
  {
    module: "Weather",
    field: "season_id",
    alias: "season_forecast",
  }
)

Copy link

changeset-bot bot commented Oct 3, 2024

⚠️ No Changeset found

Latest commit: 5dbc6c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Oct 3, 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 Oct 15, 2024 6:46pm
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Oct 15, 2024 6:46pm
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 6:46pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 6:46pm
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 6:46pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 6:46pm
resources-docs ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 6:46pm

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

@olivermrbl any suggestion here?

@thetutlage
Copy link
Contributor

Hello @carlos-r-l-rodrigues

Are read-only links used to fetch related data and does not support writes/deletes?

@adrien2p
Copy link
Member

Hello @carlos-r-l-rodrigues

Are read-only links used to fetch related data and does not support writes/deletes?

Yes that's correct, it does not create pivot table either, you just link two entities in cases where the entity already have a column that store the foreign id

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

@olivermrbl @srindom
should we merge or close this one?

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.

4 participants