Closed leandroluk closed 3 weeks ago
could you spot the latest working version?
btw don't you need to add autoSchemaFile: true
?
The error Error: Query root type must be provided.
, is because autoSchemaFile: true
is missing, see also this issue: https://github.com/nestjs/nest/issues/12364
I wonder if there is any way to prevent this
We should see in the @nestjs/graphql
package if we can return a more intuitive message instead of this error: Error: The root type of the query must be provided
, maybe it can help to better understand the error.
Please search through some of our old issues on this (this has been discussed several times in the past).
Is there an existing issue for this?
Current behavior
I am trying to create a project using NestJS + GraphQL and using the documentation and run the project I get an error message
Error: Query root type must be provided.
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-t8ae72?file=src%2Fapp.module.ts
Steps to reproduce
nest-cli.json
:src/app.resolver.ts
file:src/app.module.ts
adding graphql dependencies and the new resolver:Expected behavior
Are expected to project starts having one query called
getHello
on graphql schema.Package
Other package
@nestjs/graphql
NestJS version
10.4.4
Packages versions
{ "name": "app", "version": "0.0.1", "description": "", "author": "", "private": true, "license": "UNLICENSED", "scripts": { "build": "nest build", "format": "prettier --write \"src//*.ts\" \"test/*/.ts\"", "start": "nest start", "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}//.ts\" --fix", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { "@apollo/server": "4.11.0", "@nestjs/apollo": "12.2.0", "@nestjs/common": "^10.0.0", "@nestjs/core": "^10.4.4", "@nestjs/graphql": "12.2.0", "@nestjs/platform-express": "^10.0.0", "graphql": "16.9.0", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1" }, "devDependencies": { "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", "@types/supertest": "^6.0.0", "@typescript-eslint/eslint-plugin": "^8.0.0", "@typescript-eslint/parser": "^8.0.0", "eslint": "^8.42.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", "gts": "^5.3.1", "jest": "^29.5.0", "prettier": "^3.0.0", "source-map-support": "^0.5.21", "supertest": "^7.0.0", "ts-jest": "^29.1.0", "ts-loader": "^9.4.3", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "typescript": "^5.1.3" }, "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": "src", "testRegex": ".\.spec\.ts$", "transform": { "^.+\.(t|j)s$": "ts-jest" }, "collectCoverageFrom": [ "*/.(t|j)s" ], "coverageDirectory": "../coverage", "testEnvironment": "node" } }
Node.js version
20.17.0
In which operating systems have you tested?
Other
No response