I'm trying to setup a graphql nestjs clean architecture, I have my resolver call the service, service calls repository and repository calls orm methods. Am I missing a step?
But I get this error:
[Nest] 59764 - 03/10/2022, 16:36:13 ERROR [ExceptionHandler] Nest can't resolve dependencies of the AthleteRepository (?). Please make sure that the argument AthleteEntityRepository at index [0] is available in the GraphQLModule context. Potential solutions: - If AthleteEntityRepository is a provider, is it part of the current GraphQLModule? - If AthleteEntityRepository is exported from a separate @Module, is that module imported within GraphQLModule? @Module({ imports: [ /* the Module containing AthleteEntityRepository */ ] }) Error: Nest can't resolve dependencies of the AthleteRepository (?). Please make sure that the argument AthleteEntityRepository at index [0] is available in the GraphQLModule context. This is my module:
@Module({ imports: [ InfraestructureModule, NestGraphqlModule.forRoot<MercuriusDriverConfig>({ driver: MercuriusDriver, graphiql: true, autoSchemaFile: join( process.cwd(), 'src/infraestructure/graphql/schema.gql', ), sortSchema: true, }), ], controllers: [AuthResolver, UserResolver], providers: [ FirebaseService, AthleteEntity, AthleteRepository, AthleteService, ], }) export class GraphQLModule {} Adding repository by comment request, it's mostly just wrappers around the typerom Repository.
import { Controller } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { AthleteEntity } from '../entity/athlete.entity'; @Controller('') export class AthleteRepository { constructor( @InjectRepository(AthleteEntity) private athleteRepository: Repository<AthleteEntity>, ) {} async getAthleteByUserId(id: string): Promise<AthleteEntity> { return this.athleteRepository.findOne({ where: { id } }); } async getAthletes(): Promise<AthleteEntity[]> { return this.athleteRepository.find(); } }
AthleteRepositoryclass