[ ] 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.
Error out when starting the dev server. See: https://codesandbox.io/s/gifted-black-rtzun?file=/package.json
```[20:42:42] Starting compilation in watch mode...
[20:42:44] Found 0 errors. Watching for file changes.
Debugger listening on ws://127.0.0.1:9229/9b8e820d-ff88-4e22-a694-e48e5b1aa6af
For help, see: https://nodejs.org/en/docs/inspector
[Nest] 60446 - 04/27/2020, 20:42:45 [NestFactory] Starting Nest application...
[Nest] 60446 - 04/27/2020, 20:42:45 [InstanceLoader] AppModule dependencies initialized +13ms
[Nest] 60446 - 04/27/2020, 20:42:45 [InstanceLoader] GraphQLSchemaBuilderModule dependencies initialized +1ms
[Nest] 60446 - 04/27/2020, 20:42:45 [InstanceLoader] GraphQLModule dependencies initialized +0ms
[Nest] 60446 - 04/27/2020, 20:42:45 [RoutesResolver] AppController {}: +3ms
[Nest] 60446 - 04/27/2020, 20:42:45 [RouterExplorer] Mapped {, GET} route +2ms
[
GraphQLError [Object]: Query root type must be provided.
at SchemaValidationContext.reportError (dev/nest-project/node_modules/graphql/type/validate.js:88:19)
at validateRootTypes (dev/nest-project/node_modules/graphql/type/validate.js:107:13)
at validateSchema (/dev/nest-project/node_modules/graphql/type/validate.js:52:3)
at graphqlImpl (dev/nest-project/node_modules/graphql/graphql.js:79:62)
at /dev/nest-project/node_modules/graphql/graphql.js:28:59
at new Promise (
at Object.graphql (dev/nest-project/node_modules/graphql/graphql.js:26:10)
at GraphQLSchemaFactory.
at Generator.next (
at /dev/nest-project/node_modules/tslib/tslib.js:113:75 {
message: 'Query root type must be provided.'
}
]
(node:60446) UnhandledPromiseRejectionWarning: Error: Schema generation error (code-first approach)
at GraphQLSchemaFactory.
at Generator.next (
at fulfilled (dev/nest-project/node_modules/tslib/tslib.js:110:62)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:60446) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:60446) [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.
```
It doesn't crash when a resolver is supposed to be present
yarn start:devSmooth GraphQL integration
[System Information]
OS Version : macOS Catalina
NodeJS Version : v12.16.1
YARN Version : 1.22.4
[Nest CLI]
Nest CLI Version : 7.1.4
[Nest Platform Information]
platform-express version : 7.0.0
graphql version : 7.3.4
common version : 7.0.0
core version : 7.0.0
other
Tested in a node:12 docker container as well. Same result.
I've already burned down the node_module, dist and yarn.lock to see if it was a corrupt package installed by the CLI, but no change.
Codesandbox: https://codesandbox.io/s/gifted-black-rtzun?file=/package.json
A bit more information. I've found the root cause, but not sure if this is intended behavior. Reading from the docs it doesn't seem to be or I misinterpreted it. See: https://docs.nestjs.com/graphql/quick-start#multiple-endpoints
I was adding the HelloModule via the includes array explained in the above link. If I add the Module just like any other module it runs fine.
If this is intended behavior, could someone explain me why? I might be able to re-phrase some things in the documentation to avoid confusion for other people.
I was adding the HelloModule via the includes array explained in the above link. If I add the Module just like any other module it runs fine.
You should add this module in addition to listing it in the includes array.
If this is intended behavior, could someone explain me why? I might be able to re-phrase some things in the documentation to avoid confusion for other people.
includes property allows filtering what modules should be considered as part of a specific GQL schema. Still, you must indicate that they exist and import them normally as you would do with a single-endpoint application.
Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.
@kamilmysliwiec I tried that. It wasn鈥檛 super clear from the documentation (imo), but now it makes sense.
I鈥檒l try to make time today to send a PR in the docs repo.
I also has this porble. and I supposed he not add resolver into module's providers.
@Module({
imports: [
UserModule, // <--- need to add here too
GraphQLModule.forRoot({
include: [UserModule],
autoSchemaFile: true,
})
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Most helpful comment