-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
fix(medusa): Plugin repository loader #3345
Conversation
🦋 Changeset detectedLatest commit: 87de3c0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
@adrien2p Is this ready for review? |
@olivermrbl I did not test it yet, i ll do that tomorrow morning |
@olivermrbl I ve just tested it and it worked // src/repositories/user-test.ts
import { dataSource } from "@medusajs/medusa/dist/loaders/database";
import { User } from "@medusajs/medusa";
const UserRepository = dataSource.getRepository(User).extend({
test() {
return { test: "test" }
}
})
export default UserRepository and in the API directory route.get('/test', async (req, res) => {
const userTestRepo = req.scope.resolve("userTestRepository")
const test = userTestRepo.test()
res.json(test)
}) I have also tested to override an existing repo // src/repositories/user.ts
import UserRepository from "@medusajs/medusa/dist/repositories/user";
const UserRepo = UserRepository.extend({
test() {
return { test: "test" }
}
})
export default UserRepo and in the API route.get('/test', async (req, res) => {
const userTestRepo = req.scope.resolve("userTestRepository")
const test = userTestRepo.test()
const userRepo = req.scope.resolve("userRepository")
const test2 = userRepo.test()
res.json([test, test2])
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we could add an integration test :)
FIXES CORE-1177