I'm unable to use a service with a resolver in the same module. I have looked at this for at least an hour now and can't figure out what's wrong.
The auth service is in the providers array of the auth module so the auth resolver should be able to use it right?
Error: Nest can't resolve dependencies of the AuthResolver (?). Please make sure that the argument AuthService at index [0] is available in the AuthResolver context.
Potential solutions:
- If AuthService is a provider, is it part of the current AuthResolver?
- If AuthService is exported from a separate @Module, is that module imported within AuthResolver?
@Module({
imports: [ /* the Module containing AuthService */ ]
})
app.module.ts
@Module({
imports: [
MercuriusModule.forRoot({ autoSchemaFile: true, graphiql: 'playground' }),
AppResolver,
AuthModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
auth.module.ts
@Module({
imports: [AuthResolver],
providers: [AuthService],
})
export class AuthModule {}
auth.service.ts
@Injectable()
export class AuthService {}
auth.resolver.ts
@Resolver()
export class AuthResolver {
constructor(private readonly authService: AuthService) {}
@Mutation(() => Boolean)
sendMagicLink(): boolean {
return true;
}
@Mutation(() => Boolean)
signIn(): boolean {
return true;
}
@Mutation(() => Boolean)
signOut(): boolean {
return true;
}
@Mutation(() => Boolean)
revokeRefreshToken(): boolean {
return true;
}
}