[X] Feature request
I have been playing around with nest this morning and was trying to get an instance with multiple graphql endpoints. The ideas was to have a user endpoint with limited schema scope and the admin endpoint with an extended one
I based this on https://github.com/nestjs/nest/tree/master/examples/12-graphql-apollo and you can follow me through here https://github.com/makstr/nestjs-multiple-endpoints-mergeTypesByPaths
yarn install
yarn dev
http://localhost:3000/graphql
http://localhost:3000/graphiql
query allCats {
getCats{
id
name
}
}
http://localhost:3000/graphqladmin
http://localhost:3000/graphiqladmin
query allCats {
getCats{
id
name
}
}
query allDogs {
getDogs{
id
name
}
}
so on top of the "cats" module I created a sibling "dogs" module with the following directory structure:
then the src/app.module.ts imports two modules UserModule and AdminModule
import {
Module,
NestModule,
} from '@nestjs/common';
import { UserModule } from './user.module';
import { AdminModule } from './admin.module';
@Module({
imports: [
//
// UserModule,
AdminModule
]
})
export class ApplicationModule {}
https://github.com/makstr/nestjs-multiple-endpoints-mergeTypesByPaths/blob/master/src/user.module.ts
user.module imports cats and admin.module import cats and dog and I changed the glob patterns to include the appropriate schemas only in each module respectively
Nest version: 4.5.0
For Tooling issues:
- Node version: v8.1.2
- Platform: Mac
Others:
Hi @makstr,
I changed the glob patterns to include the appropriate schemas only in each module respectively
The GraphQLFactory creates resolvers by going through each module, not only these available in the current scope. For example, in the UserModule the GraphQLFactory will create resolvers that include DogsModule as well.
Allright, will need to work with that. Thank you!
Hi @makstr
Do you found a solution because i have the same problem.
I can not get both modules to run simultaneously.
I am getting errors that Query.getDogs defined in resolvers, but not in schema.
Which makes me think the graphqlfactory can only handle one set of resolvers.
I need to implement 2 GraphQL endpoint
Thanks
I'm wondering same thing , how to implement several graphQL endpoints with different schema within same nest app instance.
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.