[ ] Regression
[ x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
My configService is not injected into GraphQLModule.forRootAsync -> useFactory
config.getArray should be a existing function
app.module
GraphQLModule.forRootAsync({
imports: [
ClientModule,
AuthModule,
UserModule,
AggregationModule,
],
useFactory: async (config: ConfigService) => ({
include: [
ClientModule,
AuthModule,
UserModule,
AggregationModule,
],
autoSchemaFile: 'schema.gql', // https://github.com/nestjs/graphql/issues/205
context: (req: any) => (req),
cors: {
origin: config.getArray('FRONTEND_URL'),
},
debug: config.isDevelopment(),
playground: config.isDevelopment(),
}),
inject: [ConfigService],
}),
config.service
import { Injectable } from '@nestjs/common';
import { join } from 'path';
import * as dotenv from 'dotenv';
@Injectable()
export class ConfigService {
constructor() {
dotenv.config({
path: join(__dirname, '../../.env'),
});
}
getString(key: string): string {
return process.env[key];
}
getBoolean(key: string): boolean {
if ('true' === process.env[key]) {
return true;
}
return false;
}
getArray(key: string, separator: string = ','): any[] {
return process.env[key].split(separator);
}
isProduction(): boolean {
return 'production' === process.env.ENVIRONMENT;
}
isDevelopment(): boolean {
return 'development' === process.env.ENVIRONMENT;
}
}
Before Upgrading to the newest NestJS Version this worked as expected. Now, running npm run start:dev throws a [0] [Nest] 7066 - 2019-09-27 13:55:37 [ExceptionHandler] config.getArray is not a function +33ms Exception.
Nest version: 6.7.2
Node Version: 12.7.0
OS: Linux
```
"dependencies": {
"@nestjs/common": "^6.7.2",
"@nestjs/core": "^6.7.2",
"@nestjs/graphql": "^6.5.2",
"@nestjs/jwt": "^6.1.1",
"@nestjs/mongoose": "^6.1.2",
"@nestjs/passport": "^6.1.0",
"@nestjs/platform-express": "^6.7.2",
"apollo-server-express": "^2.9.4",
"argon2": "^0.24.1",
"class-transformer": "^0.2.3",
"class-validator": "^0.9.1",
"dotenv": "^8.1.0",
"graphql": "^14.5.8",
"graphql-tools": "^4.0.5",
"graphql-type-json": "^0.3.0",
"luxon": "^1.19.3",
"mongoose": "^5.7.1",
"ms": "^2.1.2",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.12",
"rimraf": "^2.7.1",
"rxjs": "^6.5.3",
"type-graphql": "^0.17.5",
"url-parse": "^1.4.7"
},
"devDependencies": {
"@nestjs/testing": "^6.7.2",
"@types/bcrypt": "^3.0.0",
"@types/dotenv": "^6.1.1",
"@types/express": "^4.17.1",
"@types/jest": "^23.3.13",
"@types/node": "^10.14.19",
"@types/supertest": "^2.0.7",
"@types/url-parse": "^1.4.3",
"concurrently": "^4.1.2",
"jest": "^23.6.0",
"nodemon": "^1.19.2",
"prettier": "^1.15.3",
"shipit-cli": "^5.1.0",
"shipit-deploy": "^5.1.0",
"shipit-shared": "^4.4.2",
"supertest": "^3.4.1",
"ts-jest": "24.0.2",
"ts-node": "8.1.0",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.4.3",
"wait-on": "^3.2.0"
},```
Others:
Please, provide a minimal repository which reproduces your issue.
Here you go:
https://github.com/regnerisch/nestjsbug-example
I encountered this same issue upgrading from 6.5.1 to 6.5.2 and had to roll back. Staying tuned for a fix!
Fixed in 6.5.3 :)
@kamilmysliwiec tested and fix validated! Fastest turnaround time of all time :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Fixed in 6.5.3 :)