Im using typeorm, typedi and typegraphql (not nest.js) and am trying to inject my typeorm repository into the the service but its not working
Container.set("UserRepository", dataSource.getRepository(UserEntity));
@Service()
export class UserService {
constructor(private userRepository: Repository<UserEntity>) {}
async createUser({
name,
email,
password,
}: Input {...}
The error im getting is
Service with \"MaybeConstructable<Repository>\" identifier was not found in the container. Register it before usage via explicitly calling the \"Container.set\" function or using the \"@Service()\" decorator."
even though I can print out the repository with Container.get(UserRepository)
Does anyone know what im doing wrong?
try adding this annotation to your injected repo
you may need to install the typeorm-typedi-extensions package
and make sure you have
useContainer(Container);in your bootstrapping process to register the typeorm container which should be the container from the above package