-
Notifications
You must be signed in to change notification settings - Fork 420
Open
Description
Bug Report
Current behavior
When adding multiple endpoints for graphql it gives following weird error
(node:16316) UnhandledPromiseRejectionWarning: Error: Schema must contain uniquely named types but contains multiple types named "User".
at typeMapReducer (C:\Users\arsla\Documents\nest-graphql-practice\node_modules\graphql\type\schema.js:262:13)
at Array.reduce (<anonymous>)
at new GraphQLSchema (C:\Users\arsla\Documents\nest-graphql-practice\node_modules\graphql\type\schema.js:145:28)
at GraphQLSchemaFactory.<anonymous> (C:\Users\arsla\Documents\nest-graphql-practice\node_modules\@nestjs\graphql\dist\schema-builder\graphql-schema.factory.js:28:28)
at Generator.next (<anonymous>)
at C:\Users\arsla\Documents\nest-graphql-practice\node_modules\tslib\tslib.js:113:75
at new Promise (<anonymous>)
at Object.__awaiter (C:\Users\arsla\Documents\nest-graphql-practice\node_modules\tslib\tslib.js:109:16)
at GraphQLSchemaFactory.create (C:\Users\arsla\Documents\nest-graphql-practice\node_modules\@nestjs\graphql\dist\schema-builder\graphql-schema.factory.js:23:24)
at GraphQLSchemaBuilder.<anonymous> (C:\Users\arsla\Documents\nest-graphql-practice\node_modules\@nestjs\graphql\dist\graphql-schema.builder.js:55:56)
(node:16316) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:16316) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Input Code
My appModule look the following
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { MessagesModule } from './messages/messages.module';
import { UserModule } from './user/user.module';
@Module({
imports: [
MessagesModule,
UserModule,
GraphQLModule.forRoot({
autoSchemaFile: 'userSchema.gql',
playground: true,
include: [UserModule],
path: '/user',
}),
GraphQLModule.forRoot({
autoSchemaFile: 'messageSchema.gql',
playground: true,
include: [MessagesModule],
path: '/msg',
})
],
})
export class AppModule { }Expected behavior
The error above is totally unexpected , I have taken code first approach
Also i have tried a lot but didn't find help any where.
Possible Solution
Environment
Nest version: X.Y.Z
For Tooling issues:
- Node version: v12.6.0
- Platform: Windows
Others:
"@nestjs/common": "^7.0.0",
"@nestjs/core": "^7.0.0",
"@nestjs/graphql": "^7.1.3",
"@nestjs/platform-express": "^7.0.0",
"apollo-server-express": "^2.11.0",
"graphql": "^14.6.0",
"graphql-tools": "^4.0.7",
mjmaix, Diluka, chrislambe, tmmmttech, mark-beeby and 13 moreDiluka and skozer