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

Support injecting providers into dataSourceFactory #1294

Open
1 task done
brandon-leapyear opened this issue Jun 3, 2022 · 1 comment
Open
1 task done

Support injecting providers into dataSourceFactory #1294

brandon-leapyear opened this issue Jun 3, 2022 · 1 comment
Labels

Comments

@brandon-leapyear
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

I would like to provide my own DataSource, but I need to inject my ConfigService so that I can do things in my DataSource depending on configuration.

Describe the solution you'd like

The most straightforward solution is to provide a dataSourceFactoryInject option.

A bigger change (which I think makes more sense) would be to remove dataSourceFactory and add

dataSourceProviderModify: (provider) => provider
entityManagerProviderModify: (provider) => provider

which passes in the default provider, and the user can modify whatever they want, e.g.

dataSourceProviderModify: (provider) => ({
  ...provider,
  useFactory: (typeOrmOptions, configService) => {
    return new MyDataSource(typeOrmOptions, configService)
  },
  inject: [...provider.inject, ConfigService],
})

Teachability, documentation, adoption, migration strategy

See solution.

What is the motivation / use case for changing the behavior?

See problem.

@khanh-le-otsv
Copy link

I would like to suggest this feature as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants