-
Notifications
You must be signed in to change notification settings - Fork 169
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
question: passing Container to TypeORM useContainer fails #173
Comments
Just to clarify, you are using the typeorm/typeorm-typedi-extensions package or TypeORM and TypeDI only? |
Related issue: typeorm/typeorm#7267 |
Yes I am using typeorm-typedi-extensions to inject other repositories and services as well as |
I got the same error, I removed typeorm-typedi-extensions thinking it wont be compatible with the new version and still got the same error from above. |
Can you try with newly released If you use only the decorators provided by the extension, I believe you should be good to go. However this release may not solve your problem, if you import extra stuff from TypeORM via |
@NoNameProvided I'm having the same issue and new
Still getting the The only usages of Update: |
@marines Can you provide a snippet of the code that got it working? |
I'm facing the same issue after upgrade my dependencies
Downgrading typedi to 0.7.3 make it work again |
@danbeneventano I mean it's just |
You need to add the |
I can confirm decorating all classes that fail with |
@danbeneventano here is a sample repository with steps to set it up and run it. it should fail because it cant inject the proper service. |
I have the same problem. What classes are you referring to? For me, as with your example, it is typeORMs ConnectionManager that fails. Did you manage to make that into a @service or are you referring to some other class? |
For now I have downgraded to |
@kikoanis Can I ask what services you had to decorate with |
Also, I have released For that, all services which throw an error should be pre-registered. Can we get a list of those falling services? This way there is no need for modification in TypeORM. |
That sounds great! I have only gotten this error on the class |
I am experiencing the same issue with |
@EirikFA please open an issue for that in class-validator repo. The problem there is that |
Will do! :) |
Question: external packages that generate classes will need to now add @service() to all of the internal services? what if the package can't do this, then its not really scalable? for example typegraphql-prisma, generates a load of resolvers, but none of them are now in the container. |
I imagine you could extend the generated class and annotate it? (Doesn't seem ideal, but might be a temporary solution) |
Since OP screenshotted the error, I'm going to copy and paste the message, so Google can index it:
|
Just incase this helps someone. At the time of writing, I was experiencing the same issue while using the latest versions of the following dependencies. I was able to leave TypeOrm at its latest and simply downgraded In my
Working |
In [email protected] has been added custom Container to register with TypeORM. So changing from: import { Container } from "typedi";
import { useContainer } from "typeorm";
useContainer(Container); to import { Container } from "typeorm-typedi-extensions";
import { useContainer } from "typeorm";
useContainer(Container); helps. |
Closing this as solved now. As @4matic mentioned the latest The concern raised by @JClackett is worth discussing, if anyone is affected please open a new issue discussing that specific topic. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
registering
Container
with typeorm'suseContainer
does not work anymore as of the latest release 0.9.0It throws the following error which is fine for services
Minimal code-snippet showcasing the problem
Unless I am missing something, this should not fail.
Expected behavior
It used to work fine. This has stopped working as of 0.9.0.
Actual behavior
It should not fail on passing typedi
Container
to typeormThe text was updated successfully, but these errors were encountered: