#Error when trying to make a relationship with a Medusa Entity while developing a plugin

25 messages · Page 1 of 1 (latest)

fossil gate
#

I'm trying to develop a plugin that has a relationship with the Sales Channel Entity. I don't need the Sales Channel to have the list of my custom Entity so I implemented a ManyToOne unidirectional on my CustomEntity. The code seems to work but I'm running into a TypeORM error when deploying the changes to my Medusa Backend (see image attached). I also tried to create a custom SalesChannel entity on my plugin but again I face the same issue but with the SalesChannel Location.

Could be there anything I'm doing wrong? Or, is it really not supported to reference Medusa Core Entities into custom plugins?

PS: I tried to put the same code directly into my medusa backend and everything seemed to work good, but I really need it to be a plugin to be reusable

#

In case is needed, I leave here as well how I am implementing the unidirectional ManyToOne in my CustomEntity

fossil gate
#

.

vale prism
#

It is supported, might be an issue with your migration. But hard to know without more info

fossil gate
#

First of all, thanks for your time reviewing this.

What issue on my migration could cause this to fail? I think my tables were ok since when I implemented it through my medusa backend directly (instead of the plugin) everything went well.

What kind of information do you think I could provide to you to understand the issue I'm facing deeply?

#

Also, as a workaround, I'm saving and fetching the sales channel info through the SalesChannelRepo / Service (Depending on use case) and both of those are working well on my plugin. The only thing I'm having issues with is making a relationship directly to the Entity.

arctic lintel
#

It would be nice if you share a reproducable example (e.g a partial of your plugin) that we can run and test with

fossil gate
arctic lintel
#

Thanks i ll have a look 👌

arctic lintel
#

I don't reproduce your issue, have you build your plugin and how did you registered it in your medusa-config

#

Also, you should provide an util for the user to apply a full override from the index file entry point

fossil gate
#

I did built the plugin, and I registered the plugin just as I say in the README of the plugin, like this:

#

I don't think I fully understand your last sentence, is that an util I'll have to develop and implement in my backend?

Also, it would be helpful if you tell me if you did anything else than what's specified on the README since those are the steps I'm doing and maybe I'm missing something

arctic lintel
#

I think the issue is how you might test your plugin locally, since you are linking the package, can you try to run the following command node --preserve-symlinks ./index.js

#

I believe the issue is due to your node modules from your plugin when it gets linked

fossil gate
#

I don't have any index file in my medusa backend, I run it with "medusa start" command

#

Is there a way to put that flag with that command? Or any workaround on this?

fossil gate
#

I just added the medusa plugin as a dependency and it worked.

#

Is there any workaround for testing on this? It would be very messy if I had to commit for every change I want to test

arctic lintel
#

You can pick the custom entry point and the script from the starter it is the easiest way

fossil gate
#

Sorry but I didn't understand what I have to do for testing it. I would appreciate if you could explain it in another way.

#

Also, should I create a bug report? At least in the documentation it is encouraged to test the plugins the way I was doing. Maybe it's just updating the documentation or your team could think of another way of solving this testing issue, because most likely if people follows the docs they will find out this issue as well.

arctic lintel
#

In the doc, it is explained that if you do it that way you have to remove some node modules which I am not sure you have done. This is not a bug but we will try to improve the doc. This is a common issue with linking package and the nodejs doc explain that well if you look at the doc for the flag I ve provided you with

#
GitHub

Contribute to medusajs/medusa-starter-default development by creating an account on GitHub.

GitHub

Contribute to medusajs/medusa-starter-default development by creating an account on GitHub.

#

this as been answered plenty of time on discord as well