25 lines
847 B
TypeScript
25 lines
847 B
TypeScript
import { MiddlewareConsumer, Module } from '@nestjs/common';
|
|
import { GraphQLModule } from '@nestjs/graphql';
|
|
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
|
import { PrismaService } from '../prisma/prisma.service';
|
|
import { schema } from './schema';
|
|
import { GraphQLValidationMiddleware } from 'src/middlewares/graphql.middleware';
|
|
@Module({
|
|
imports: [
|
|
GraphQLModule.forRoot<ApolloDriverConfig>({
|
|
driver: ApolloDriver,
|
|
schema: schema,
|
|
debug: true,
|
|
allowBatchedHttpRequests: true,
|
|
introspection: true,
|
|
}),
|
|
],
|
|
providers: [PrismaService],
|
|
})
|
|
export class GraphqlModule {
|
|
configure(consumer: MiddlewareConsumer) {
|
|
consumer
|
|
.apply(GraphQLValidationMiddleware) // Apply the custom middleware
|
|
.forRoutes('graphql'); // Ensure it only applies to the /graphql endpoint
|
|
}
|
|
} |