fix: Using Typeorm DataSource and Typegraphql: Cannot get Connection with name \"default\" from the ConnectionManager. #60
Labels
status: needs triage
Issues which needs to be reproduced to be verified report.
type: fix
Issues describing a broken feature.
Description
Using Typeorm's new way of connecting to a data source with
new Typeorm.DataSource({...})
, we cannot access the global typeorm connection through the typedi container. I'm using Typegraphql and when I run a query I get the response error:Cannot get Connection with name \"default\" from the ConnectionManager. Make sure you have created the connection and called \"useContainer(Container)\" in your application before establishing a connection and importing any entity into TypeORM.
It only works if we create the connection using the now deprecated
Typeorm.createConnection
.As a side note, Typeorm has deprecated all container-related features in 0.3.0. How will this affect the future of this package and Typedi as a whole?
Minimal code-snippet showcasing the problem
Expected behavior
I expected to my query to be able to find the injected Repository and Connection and run the query.
Actual behavior
Typegraphql sends back the response:
Cannot get Connection with name \"default\" from the ConnectionManager. Make sure you have created the connection and called \"useContainer(Container)\" in your application before establishing a connection and importing any entity into TypeORM.
The text was updated successfully, but these errors were encountered: