type-graphql-dataloader icon indicating copy to clipboard operation
type-graphql-dataloader copied to clipboard

Support for typeorm v0.3+

Open ejekanshjain opened this issue 2 years ago • 3 comments

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

ejekanshjain avatar Apr 18 '22 11:04 ejekanshjain

Anyone have a work around for this?

ghost avatar Apr 21 '22 17:04 ghost

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

ghost avatar Apr 21 '22 18:04 ghost

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.

michaelm244 avatar Jun 09 '22 18:06 michaelm244