1
1
import { join } from 'path' ;
2
2
import { Module } from '@nestjs/common' ;
3
- import { ConfigModule } from '@nestjs/config' ;
3
+ import { ConfigModule , ConfigService } from '@nestjs/config' ;
4
4
import { GraphQLModule } from '@nestjs/graphql' ;
5
5
import { ApolloDriver , ApolloDriverConfig } from '@nestjs/apollo' ;
6
6
import config from './config' ;
@@ -11,11 +11,15 @@ import { SampleModule } from './sample/sample.module';
11
11
controllers : [ AppController ] ,
12
12
imports : [
13
13
ConfigModule . forRoot ( { isGlobal : true , load : [ config ] } ) ,
14
- GraphQLModule . forRoot < ApolloDriverConfig > ( {
14
+ GraphQLModule . forRootAsync < ApolloDriverConfig > ( {
15
15
driver : ApolloDriver ,
16
- autoSchemaFile : join ( process . cwd ( ) , 'src/schema.gql' ) ,
17
- debug : true ,
18
- playground : true ,
16
+ imports : [ ConfigModule ] ,
17
+ useFactory : async ( configService : ConfigService ) => ( {
18
+ autoSchemaFile : join ( process . cwd ( ) , 'src/schema.gql' ) ,
19
+ debug : configService . get ( 'graphql' ) . debug ,
20
+ playground : configService . get ( 'graphql' ) . playground ,
21
+ } ) ,
22
+ inject : [ ConfigService ] ,
19
23
} ) ,
20
24
SampleModule ,
21
25
] ,
0 commit comments