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

EntityManager doesn't work with existing TypeORM project #47

Open
claytoncasey01 opened this issue Nov 2, 2018 · 2 comments
Open

EntityManager doesn't work with existing TypeORM project #47

claytoncasey01 opened this issue Nov 2, 2018 · 2 comments

Comments

@claytoncasey01
Copy link

We are working with an existing TypeORM project and have been working on getting things moved over to Vesper recently. The samples work just fine but when we use our existing Database and TypeORM models the injected EntityManger in Controllers does not contain the needed connection data.

It does connect properly to the database, if we change the password it fails to start due to MySQL issues.

Here is a screenshot inside the startup of Vesper where the connection looks fine:
screen shot 2018-11-02 at 1 36 08 pm

After startup in the controller:
screen shot 2018-11-02 at 12 38 49 pm

Error in playground:
screen shot 2018-11-02 at 1 43 47 pm

@solarflare045
Copy link

This seems to be caused by the controller referencing a different instance of TypeORM to Vesper.

Changing the import line to this solved the issue for me:
import { EntityManager } from 'vesper/node_modules/typeorm';

@wufe
Copy link

wufe commented May 21, 2019

I solved tried solving registering the EntityManager:

import { bootstrap } from "vesper";
import { ManufacturerController } from "presentation/web/controllers/manufacturer-controller";
import { Manufacturer } from "entities/manufacturer";
import { Connection, EntityManager, getManager } from "typeorm";

export const init = (connection: Connection) => new Promise(resolve => {
	bootstrap({
		port: 3001,
		controllers: [
			ManufacturerController
		],
		entities: [
			Manufacturer
		],
		schemas: [
			`${__dirname}/../infrastructure/schema/**/*.graphql`
		],
		graphIQLRoute: '/graphiql',
		setupContainer: async (container, action) => {
			container.set(EntityManager, getManager())
		}
	}).then(resolve)
});

UPDATE:
Relations do not work registering the EntityManager

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

3 participants