refactor api
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user