refactor api

This commit is contained in:
2024-10-13 18:07:13 +07:00
parent 263ff4e207
commit 1f86786e1a
7 changed files with 29 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
import { ApolloDriverConfig } from '@nestjs/apollo';
import { Global, MiddlewareConsumer, Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ConfigModule } from '@nestjs/config';
import { PothosModule } from '@smatch-corp/nestjs-pothos';
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver';
import { Builder } from './graphql.builder';
@@ -31,6 +32,7 @@ import { UploadedDocumentModule } from '../UploadedDocument/uploadeddocument.mod
@Global()
@Module({
imports: [
ConfigModule.forRoot(),
PrismaModule,
UserModule,
CenterModule,
@@ -60,6 +62,9 @@ import { UploadedDocumentModule } from '../UploadedDocument/uploadeddocument.mod
}),
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: PothosApolloDriver,
path: process.env.API_PATH + '/graphql',
playground: true,
introspection: true,
}),
],
providers: [
@@ -80,6 +85,6 @@ export class GraphqlModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(GraphQLValidationMiddleware) // Apply the custom middleware
.forRoutes('graphql'); // Ensure it only applies to the /graphql endpoint
.forRoutes(process.env.API_PATH + '/graphql'); // Ensure it only applies to the /graphql endpoint
}
}