You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prisma generates types, so using Pojos. But getting error on creating the app
Nest can't resolve dependencies of the TestProfile (?). Please make sure that the argument "automapper:nestjs:default" at index [0] is available in the TestModule context.
Have posted this on StackOverflow, but though might get a quicker resolution here:
Below is the code:
app.module.ts
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AutomapperModule } from '@automapper/nestjs';
import { pojos } from '@automapper/pojos';
import { TestModule } from './test/test.module';
@Module({
imports: [
AutomapperModule.forRoot(
[
{
name: 'pojos',
strategyInitializer: pojos(),
},
],
),
TestModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
test.module.ts
import { Module } from '@nestjs/common';
import { TestController } from './test.controller';
import { TestService } from './test.service';
import { PrismaService } from 'prisma/prisma.service';
import { TestProfile } from 'src/automapper/test.profile';
import { AutomapperModule } from '@automapper/nestjs';
import { pojos } from '@automapper/pojos';
@Module({
imports: []
controllers: [TestController],
providers: [PrismaService, TestProfile, TestService],
exports: [TestService],
})
export class TestModule {}
test.profile.ts
import { AutomapperProfile, InjectMapper } from '@automapper/nestjs';
import { createMap, type Mapper } from '@automapper/core';
import { Injectable } from '@nestjs/common';
import { TestDto } from './Test.dto';
import { Test } from '@prisma/client';
import { PojosMetadataMap } from "@automapper/pojos";
@Injectable()
export class TestProfile extends AutomapperProfile {
constructor(@InjectMapper() mapper: Mapper) {
super(mapper);
createTestMetadata();
}
function createTestMetadata() {
PojosMetadataMap.create<Test>('Test', {
id: String,
description: String
});
PojosMetadataMap.create<TestDto>('TestDto', {
id: String,
description: String,
comment: String
});
}
override get profile() {
return (mapper: Mapper) => {
createMap<Test, TestDto>(
mapper,
'Test',
'TestDto',
);
};
}
}
This whole gives the error as mentioend in the beginning. If I remove the TestProfile in the providers for TestModule, then all works fine, but AutoMapper won't work.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Prisma generates types, so using Pojos. But getting error on creating the app
Nest can't resolve dependencies of the TestProfile (?). Please make sure that the argument "automapper:nestjs:default" at index [0] is available in the TestModule context.
Have posted this on StackOverflow, but though might get a quicker resolution here:
Below is the code:
app.module.ts
test.module.ts
test.profile.ts
Test Dto object is defined as
Original Test Type is defined in Prisma model
This whole gives the error as mentioend in the beginning. If I remove the TestProfile in the providers for TestModule, then all works fine, but AutoMapper won't work.
What is going wrong here?
Beta Was this translation helpful? Give feedback.
All reactions