nest-schedule icon indicating copy to clipboard operation
nest-schedule copied to clipboard

Issues with injecting other services

Open kunokdev opened this issue 5 years ago • 1 comments

Hello, first of all, this is a very nice module;

I've been using scheduler service in such way:

@Injectable()
export class ScheduleService extends NestSchedule {
  constructor(
    @InjectModel("Subscription") private readonly Subscription: Model<ISubscriptionInstance>,
    @Inject("NotificationService") private readonly notificationService: NotificationService
  ) {
    super();
  }

  @Interval(config.scheduleInterval, {
    immediate: true
  })
  async intervalJob() {
    // ...
  }
}

I've been able to successfully inject models, but I am unable to inject other service, as I am getting this error:

Nest can't resolve dependencies of the NotificationService (?). Please make sure that the argument at index [0] is available in the NotificationService context.

Is that limitation of the lib or I am doing something wrong? I've been able to inject services in other modules just fine.

kunokdev avatar Jun 03 '19 16:06 kunokdev

Please check NotificationService constructor index[0] parameter, nest inject it fail

miaowing avatar Jun 04 '19 02:06 miaowing