Refactor code structure and dependencies
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
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>({
|
||||
@@ -15,4 +16,10 @@ import { schema } from './schema';
|
||||
],
|
||||
providers: [PrismaService],
|
||||
})
|
||||
export class GraphqlModule {}
|
||||
export class GraphqlModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer
|
||||
.apply(GraphQLValidationMiddleware) // Apply the custom middleware
|
||||
.forRoutes('graphql'); // Ensure it only applies to the /graphql endpoint
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user