Apollo Server Setup
- nestJs의 graphQL은 apollo-server-express를 기반하여 작동한다.
- setting
npm i @nestjs/graphql graphql-tools graphql apollo-server-express
- app.module.ts
import { GraphQLModule } from '@nestjs/graphql';
@Module({
imports: [GraphQLModule.forRoot({
autoSchemaFile: true,
})],
controllers: [],
providers: [],
})
export class AppModule {}
Validation ArgsType
- Ex) @IsString, @Length ...
- setting
npm i class-validator class-transformer
- main.ts
import { ValidationPipe } from '@nestjs/common';
async function bootstrap() {
app.useGlobalPipes(new ValidationPipe());
}
bootstrap();