#Getting Dependency Error

24 messages · Page 1 of 1 (latest)

mossy yew
#

Nest can't resolve dependencies of the TransactionService (LoggerSrv, TransactionModel, ?, TransactionCategoryV2Model, TransactionModesModel, TransactionCallbackModel, TransactionFailModel, PayeeModel, REQUEST, ConfigService, TransactionApiService, AccountApiService, WealthItcApiService, ValidateObject, RRNExtractionService, TransactionCategorizationService, CryptoService, RedisService, RequestHelper, SQSHelper, OneAppKafkaPublisherApi, KafkaPublisherService, CacheManagerService). Please make sure that the argument TransactionCategoryModel at index [2] is available in the TransactionPrivateModule context.

Potential solutions:

  • If TransactionCategoryModel is a provider, is it part of the current TransactionPrivateModule?
  • If TransactionCategoryModel is exported from a separate @Module, is that module imported within TransactionPrivateModule?
    @Module({
    imports: [ /* the Module containing TransactionCategoryModel */ ]
    })
#
   private readonly logger: LoggerSrv,
    @InjectModel('Transaction') private readonly transactionModel: PaginateModel<TransactionInterface>,
    @InjectModel('TransactionCategory') private readonly transactionCategoryModel: Model<TransactionCategoryInterface>,
    @InjectModel('TransactionCategoryV2') private readonly transactionCategoryModelV2: Model<TransactionCategoryInterfaceV2>,
    @InjectModel('TransactionModes') private readonly transactionModesModel: Model<TransactionModesInterface>,
    @InjectModel('TransactionCallback') private readonly transactionCallbackModel: Model<TransactionCallbackInterface>,
    @InjectModel('TransactionFail') private readonly transactionFailModel: PaginateModel<TransactionFail>,
    @InjectModel('Payee') private readonly payeeModel: Model<PayeeInterface>,
    @Inject(REQUEST) private request: Request,
    private configService: ConfigService,
    private transactionsApiService: TransactionApiService,
    private accountApiService: AccountApiService,
    private wealthItcApiService: WealthItcApiService,
    private readonly validate: ValidateObject,
    private readonly rrnExtractionService: RRNExtractionService,
    private readonly categorizationService: TransactionCategorizationService,
    private cryptoSrv: CryptoService,
    private readonly redisService: RedisService,
    private requestHelper: RequestHelper,
    private sqsHelper: SQSHelper,
    private oneAppKafkaPublisher: OneAppKafkaPublisherApi,
    private readonly kafkaService: KafkaPublisherService,
    private readonly cacheManagerService:CacheManagerService
  ) { ```
#
     private transactionPrivateService: TransactionPrivateService,
        private logger: LoggerSrv,
        @Inject(REQUEST) private request: Request,
        @Inject(forwardRef(() => TransactionService))
        private readonly transactionService : TransactionService
      ) { } ```
fleet forgeBOT
#

Suggestion for @mossy yew:
Please format your question or answer with Markdown formatting.
It leads to better readability and an easier time to spot problems.
For code blocks, you can wrap your block with three back ticks before and after the block, and after the first three back ticks you can add a language (like ts) to add syntax highlighting.
e.g.

```ts
@Injectable()
export class MySuperAwesomeService {
constructor(@Inject('InjectionToken') private readonly dep: SomeDependency) {}

getRandomNumber(): number {
return Math.round(Math.random() * 1000);
}
}
```

Becomes :point_down:

@Injectable()
export class MySuperAwesomeService {
  constructor(@Inject('InjectionToken') private readonly dep: SomeDependency) {}

  getRandomNumber(): number {
    return Math.round(Math.random() * 1000);
  }
}
keen dawn
#

show us imports at TransactionPrivateModule module

mossy yew
#
    { name: 'TransactionPeriodicRefresh', schema: TransactionPeriodicRefreshSchema },
    { name: 'Transaction', schema: TransactionSchema }
  ]),forwardRef(() => TransactionModule)],
  controllers: [TransactionPrivateController],
  providers: [TransactionPrivateService,TransactionService]
})
export class TransactionPrivateModule {}
keen dawn
#

looks like you didn't registered the TransactionCategory anywhere

#

follow the docs

mossy yew
#

if I register then again it ask for more dependency to register

#

my requirement to call transactionservice function from transactionprivatecontroller class

desert dagger
#

looks like circular dependency

mossy yew
#

tried this also but did not solve the issue

scarlet patrol
mossy yew
#

yes

scarlet patrol
#

Does your TransactionModule have the TransactionService in the exports array as well as the providers array

mossy yew
#

yes

scarlet patrol
#

Then remove TransactionService from the TransactionPrivateModule

mossy yew
#

after removing I am getting below error ``` Nest can't resolve dependencies of the TransactionPrivateService (LoggerSrv, AccountApiService, KafkaPublisherService, TransactionPeriodicRefreshModel, TransactionModel, ?). Please make sure that the argument TransactionService at index [5] is available in the TransactionPrivateModule context.

Potential solutions:

  • If TransactionService is a provider, is it part of the current TransactionPrivateModule?
  • If TransactionService is exported from a separate @Module, is that module imported within TransactionPrivateModule?
    @Module({
    imports: [ /* the Module containing TransactionService */ ]
    })
scarlet patrol
#

Can you show TransactionModule?

mossy yew
#
  imports: [
    HttpModule,
    AccountModule,
    MongooseModule.forFeature([
      { name: 'TransactionCategory', schema: TransactionCategorySchema },
      { name: 'TransactionCategoryV2', schema: TransactionCategorySchemaV2 },
      { name: 'TransactionModes', schema: TransactionModesSchema },
      { name: 'TransactionCallback', schema: TransactionCallbackSchema },
      { name: 'TransactionFail', schema: TransactionFailSchema },
      { name: 'Payee', schema: PayeeSchema },
    ]),
   ],
  controllers: [
    TransactionController,
    TransactionControllerV2,
    TransactionCategoryController,
    TransactionCategoryControllerV2,
    TransactionStatsController,
    TransactionStatsControllerV2,
    TransactionModesController    
  ],
  providers: [
    TransactionService,
  
  ],
  exports: [TransactionService]
})
export class TransactionModule {}. ```
scarlet patrol
#

Okay, and the constructor for TransactionPrivateService?

#

Also, do the TransactionModule and the TransactionPrivateService use the same casing for the import of the TransactionService?

mossy yew
#

thanks it is resolved by importing transaction module in transaction private module