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

registerAsync is not passing imports array #1

Open
cojack opened this issue Jan 12, 2021 · 3 comments
Open

registerAsync is not passing imports array #1

cojack opened this issue Jan 12, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@cojack
Copy link

cojack commented Jan 12, 2021

As in topic, because of this I'm not able to create an app:

        QueueModule.registerAsync({
            isGlobal: true,
            useClass: AppQueueService,
            imports: []
        }),

It returns me an error:

[Nest] 26166   - 01/12/2021, 1:25:20 PM   [ExceptionHandler] Nest can't resolve dependencies of the __QUEUE_OPTIONS__ (?). Please make sure that the argument AppQueueService at index [0] is available in the QueueModule context.

Potential solutions:                                                                                                                                                                                                                                                                                                       
- If AppQueueService is a provider, is it part of the current QueueModule?                                                                                                                                                                                                                                                 
- If AppQueueService is exported from a separate @Module, is that module imported within QueueModule?                                                                                                                                                                                                                      
  @Module({
    imports: [ /* the Module containing AppQueueService */ ]
  })
 +0ms

Where class looks like this:

@Injectable()
export class AppQueueService implements QueueAsyncOptionsFactory {
    constructor(
        @Inject(awsConfig.KEY)
        private readonly configAws: ConfigType<typeof awsConfig>
    ) {}
}
@vinayak25
Copy link
Contributor

Hi @cojack, I will the check the useClass issue, shouldn't be happening. But for the time being can you try using the imports with useFactory setting and let us know if it is working fine.

I will be debugging and releasing an updated version of the package soon with the bug fix.

@cojack
Copy link
Author

cojack commented Jan 12, 2021

@vinayak25 yes, useFactory is working

        QueueModule.registerAsync({
            isGlobal: true,
            useFactory: (configAws) => (new AppQueueService(configAws)).createQueueOptions(),
            inject: [awsConfig.KEY],
            imports: []
        }),

@vinayak25 vinayak25 self-assigned this Jan 12, 2021
@vinayak25 vinayak25 added the bug Something isn't working label Jan 12, 2021
@vinayak25
Copy link
Contributor

vinayak25 commented Jan 13, 2021

Thanks for the update @cojack, request you to please go forward with the useFactory configuration only. I will be releasing a new version with the bug fix soon or please feel free to raise a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants