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

Linking is not working with latest update #15

Open
AvinashMudunuri opened this issue Jan 2, 2025 · 1 comment
Open

Linking is not working with latest update #15

AvinashMudunuri opened this issue Jan 2, 2025 · 1 comment

Comments

@AvinashMudunuri
Copy link

@rpuls , could you take a look at this please, i was trying to extend Customer module with custom module (OTP). OTP model generation, db migrate worked well, but when created customer-otp link and executing the npx medusa db:sync-links. getting below error.

`import { model } from "@medusajs/utils";

export const Otp = model.define("otp", {
id: model.id().primaryKey(),
otp: model.text().nullable(),
otpExpiresAt: model.dateTime().nullable(),
isPhoneVerified: model.boolean().default(false),
});`

`import OtpModule from "../modules/otp";
import CustomerModule from "@medusajs/medusa/customer";
import { defineLink } from "@medusajs/framework/utils";

export default defineLink(
{
linkable: CustomerModule.linkable.customer,
isList: true,
},
OtpModule.linkable.otp
);
`

error: Invalid linkable passed for the argument
undefined
Error: Invalid linkable passed for the argument
s.pnpm@medusajs+utils@2.0.4_@mikro-orm+core@5.9.7_@mikro-orm+knex@5.9.7_@mikro-orm+core@5.9.7_@mikr_gdzdwes776ftmcovhjiwdeca4i\node_modules@medusajs\utils\src\modules-sdk\define-link.ts:187:23)
at Object. (C:\Users\avina\Desktop\Projects\medusajs-2.0-for-railway-boilerplate\backend\srcs.pnpm@medusajs+utils@2.0.4_@mikro-orm+core@5.9.7_@mikro-orm+knex@5.9.7_@mikro-orm+core@5.9.7_@mikr_gdzdwes776ftmcovhjiwdeca4i\node_modules@medusajs\utils\src\modules-sdk\define-link.ts:187:23)
at Object. (C:\Users\avina\Desktop\Projects\medusajs-2.0-for-railway-boilerplate\backend\src\links\customer-otp.ts:5:26)
at Module.compile (node:internal/modules/cjs/loader:1369:14)
at Module.m.compile (C:\Users\avina\Desktop\Projects\medusajs-2.0-for-railway-boilerplate\backend\node_modules.pnpm\ts-node@10.9.2@swc+core@1.5.7
@swc+helpers@0.5.15__@types+node@20.17.6_typescript@5.6.3\node_modules\ts-node\src\index.ts:1618:23)
at Module.extensions..js (node:internal/modules/cjs/loader:1427:10)
at Object.require.extensions. [as .ts] (C:\Users\avina\Desktop\Projects\medusajs-2.0-for-railway-boilerplate\backend\node_modules.pnpm\ts-node@10.9.2
@swc+core@1.5.7_@swc+helpers@0.5.15__@types+node@20.17.6_typescript@5.6.3\node_modules\ts-node\src\index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Function.Module._load (node:internal/modules/cjs/loader:1022:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)

@rpuls
Copy link
Owner

rpuls commented Jan 3, 2025

Hi @AvinashMudunuri

I am not entirely familiar with this, so I am not sure I can tell you what's wrong.

However, I think the error indicates that either CustomerModule.linkable.customer or OtpModule.linkable.otp are undefined. But both are expected to be valid linkable objects provided by their respective modules. I am not sure exactly to to debug this within your setup..

I also notice that you are still on version 2.0.4. I have updated to 2.1.3 where there have been made a some changes to the schema, and things might work a little differently - I am not sure updating will resolve your problem, but maybe it is worth updating before resolving it.

If you do update, and you need to re-seed your database, please be aware that you need an up-to-date seed script that matches the schema changes. You can find mine for version 2.1.3 here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants