title: Nest can't resolve dependencies of the BlahService although it is Global()
body: <p>I have an issue with NestJS and it appears to be for just 1 module and all the others work fine. I have the following modules.</p>
  
  <p>The error is:</p>
  
  <pre><code>[ExceptionHandler] Nest can't resolve dependencies of the ApplicationService (ApplicationModel, AwsService, UserService, ?, JobService). Please make sure that the argument at index [3] is available in the ApplicationModule context.
  </code></pre>
  
  <p>The <code>AgencyService</code> is <code>[3]</code>. If I remove the <code>AgencyModule</code> from the <code>ApplicationModule</code> NestJS successfully compiles and I can make API calls.</p>
  
  <pre><code>AgencyModule,
  ApplicationModule,
  AuthModule,
  JobModule,
  UserModule,
  </code></pre>
  
  <p>All these modules are required by other modules for their service providers so rather than import them between each other using <code>forwardRef()</code> I just made them <code>Global()</code> - May not be best practice but hey ho (it works).</p>
  
  <p>My <code>AppModule</code> file.</p>
  
  <pre><code>@Module({
    imports: [
      MongooseModule.forRootAsync({
        useFactory: (configService: ConfigService) =&gt; ({
          uri: configService.get('MONGO_DB_URL'),
          useNewUrlParser: true,
        }),
        imports: [ConfigModule],
        inject: [ConfigService],
      }),
      ConfigModule,
      AgencyModule,
      ApplicationModule,
      AuthModule,
      DevModule,
      JobModule,
      UserModule,
      VideoModule,
    ],
    controllers: [AppController],
    providers: [AppService],
  })
  export class AppModule {}
  </code></pre>
  
  <p>Each module folder has the following structure.</p>
  
  <pre><code>agency/
  - dto/
  - agency.controller.ts
  - agency.interface.ts
  - agency.schema.ts
  - agency.service.ts
  - agency.module.ts
  </code></pre>
  
  <p>My <code>AgencyModule</code> file.</p>
  
  <pre><code>@Global()
  @Module({
    imports: [
      SharedModule,
      MongooseModule.forFeature([{ name: 'Agency', schema: AgencySchema }]),
    ],
    controllers: [
      AgencyController,
    ],
    providers: [
      AgencyService,
      AwsService,
    ],
    exports: [
      AgencyService,
    ],
  })
  export class AgencyModule implements NestModule {
    public configure(consumer: MiddlewareConsumer) {
      consumer
        .apply()
        .forRoutes(
          { path: 'agency', method: RequestMethod.GET },
        );
    }
  }
  </code></pre>
  
  <p>My <code>AgencyService</code> file.</p>
  
  <pre><code>@Injectable()
  export class AgencyService {
    constructor(
      @InjectModel('Agency') private readonly agencyModel: Model&lt;Agency&gt;,
      private readonly awsService: AwsService,
      private readonly applicationService: ApplicationService,
    ) {
      //
    }
  
    // More stuff here but not worth adding to the snippet.
  
  }
  </code></pre>
  
  <p>My <code>ApplicationModule</code> file.</p>
  
  <pre><code>@Global()
  @Module({
    imports: [
      SharedModule,
      MongooseModule.forFeature([{ name: 'Application', schema: ApplicationSchema }]),
    ],
    controllers: [
      ApplicationController,
    ],
    providers: [
      ApplicationService,
      AwsService,
    ],
    exports: [
      ApplicationService,
    ],
  })
  export class ApplicationModule implements NestModule {
    public configure(consumer: MiddlewareConsumer) {
      consumer
        .apply()
        .forRoutes(
          { path: 'application', method: RequestMethod.GET },
        );
    }
  }
  </code></pre>
  
  <p>My <code>ApplicationService</code> file.</p>
  
  <pre><code>@Injectable()
  export class ApplicationService {
    constructor(
      @InjectModel('Application') private readonly applicationModel: Model&lt;Application&gt;,
      private readonly awsService: AwsService,
      private readonly userService: UserService,
      private readonly agencyService: AgencyService,
      private readonly jobService: JobService,
    ) {
      //
    }
  
    // More stuff here but not worth adding to the snippet.
  
  }
  </code></pre>
  
  <p>The <code>AwsService</code> is a shared service without a module.</p>