type-graphql-dataloader
type-graphql-dataloader copied to clipboard
Support for typeorm v0.3+
Recently typeorm updated their package to 0.3 which changed connection methods. So getConnection doesn't work.
https://github.com/typeorm/typeorm/releases/tag/0.3.0
Anyone have a work around for this?
Anyone have a work around for this?
I think you could do something like this:
const connection = await new DataSource(require('../orm.config.js')).initialize();
ApolloServerLoaderPlugin({
typeormGetConnection: () => connection,
}),
However, I believe upgrading TypeOrm to 0.3 is breaking a dependency. I am getting Cannot find module 'typeorm'
error from the dataloader
In 0.3 Typeorm just renamed Connection
to DataSource
, so @CMethoddata's snippet works (that's what I'm using). I'm on Typeorm 0.3.6 and using this library successfully.