Closed peterbabic closed 5 years ago
Update @nestjs/graphql
to the latest version
Thank You for the reply but unfortunately:
git clone https://github.com/nestjs/nest.git
cd nest/sample/22-graphql-prisma
npm install
npm run start
produces
[Nest] 564 - 2019-05-16 10:53 [NestFactory] Starting Nest application...
[Nest] 564 - 2019-05-16 10:53 [InstanceLoader] ApplicationModule dependencies initialized +180ms
[Nest] 564 - 2019-05-16 10:53 [InstanceLoader] PrismaModule dependencies initialized +3ms
[Nest] 564 - 2019-05-16 10:53 [InstanceLoader] PostsModule dependencies initialized +3ms
[Nest] 564 - 2019-05-16 10:53 [InstanceLoader] GraphQLModule dependencies initialized +3ms
(node:564) UnhandledPromiseRejectionWarning: Error: Unknown directive "unique".
Unknown directive "default".
at assertValidSDL (/mnt/d/dev/_learn/nest/nest/sample/22-graphql-prisma/node_modules/graphql/validation/validate.js:89:11)
at Object.buildASTSchema (/mnt/d/dev/_learn/nest/nest/sample/22-graphql-prisma/node_modules/graphql/utilities/buildASTSchema.js:78:34)
at Object.buildSchemaFromTypeDefinitions (/mnt/d/dev/_learn/nest/nest/sample/22-graphql-prisma/node_modules/graphql-tools/src/generate/buildSchemaFromTypeDefinitions.ts:43:32)
at Object.makeExecutableSchema (/mnt/d/dev/_learn/nest/nest/sample/22-graphql-prisma/node_modules/graphql-tools/src/makeExecutableSchema.ts:52:16)
at GraphQLFactory.<anonymous> (/mnt/d/dev/_learn/nest/nest/sample/22-graphql-prisma/node_modules/@nestjs/graphql/dist/graphql.factory.js:68:62)
at Generator.next (<anonymous>)
at /mnt/d/dev/_learn/nest/nest/sample/22-graphql-prisma/node_modules/@nestjs/graphql/dist/graphql.factory.js:16:71
at new Promise (<anonymous>)
at __awaiter (/mnt/d/dev/_learn/nest/nest/sample/22-graphql-prisma/node_modules/@nestjs/graphql/dist/graphql.factory.js:12:12)
at GraphQLFactory.mergeOptions (/mnt/d/dev/_learn/nest/nest/sample/22-graphql-prisma/node_modules/@nestjs/graphql/dist/graphql.factory.js:41:16)
(node:564) 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: 3)
(node:564) [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.
No mention about type-graphql
package though.
+1 exactly the same for me
Update your packages to the latest @nestjs/graphql
thansk for the reply. the @nestjs/graphql package is at version 6.2.4
this is my package.json :
{
"name": "nest-typescript-starter",
"version": "1.0.0",
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"start": "ts-node src/main",
"prestart:prod": "npm run build",
"start:prod": "node dist/main.js"
},
"dependencies": {
"@nestjs/common": "6.3.1",
"@nestjs/core": "6.3.1",
"@nestjs/graphql": "6.2.4",
"@nestjs/platform-express": "6.3.1",
"apollo-server-express": "2.6.1",
"graphql": "14.3.1",
"graphql-tools": "4.0.4",
"prisma-binding": "2.3.11",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.2",
"typescript": "3.5.1"
},
"devDependencies": {
"nodemon": "1.19.1",
"prettier": "1.17.1",
"ts-node": "8.2.0",
"tsconfig-paths": "3.8.0",
"tslint": "5.17.0"
}
}
I have the same error than @peterbabic when I run npm run start:
[Nest] 6893 - 2019-06-06 18:17 [NestFactory] Starting Nest application...
[Nest] 6893 - 2019-06-06 18:17 [InstanceLoader] ApplicationModule dependencies initialized +62ms
[Nest] 6893 - 2019-06-06 18:17 [InstanceLoader] PrismaModule dependencies initialized +1ms
[Nest] 6893 - 2019-06-06 18:17 [InstanceLoader] PostsModule dependencies initialized +1ms
[Nest] 6893 - 2019-06-06 18:17 [InstanceLoader] GraphQLModule dependencies initialized +1ms
(node:6893) UnhandledPromiseRejectionWarning: Error: Unknown directive "unique".
Unknown directive "default".
at assertValidSDL (/var/node/nest-prisma/node_modules/graphql/validation/validate.js:89:11)
at Object.buildASTSchema (/var/node/nest-prisma/node_modules/graphql/utilities/buildASTSchema.js:78:34)
at Object.buildSchemaFromTypeDefinitions (/var/node/nest-prisma/node_modules/graphql-tools/src/generate/buildSchemaFromTypeDefinitions.ts:43:32)
at Object.makeExecutableSchema (/var/node/nest-prisma/node_modules/graphql-tools/src/makeExecutableSchema.ts:52:16)
at GraphQLFactory.<anonymous> (/var/node/nest-prisma/node_modules/@nestjs/graphql/dist/graphql.factory.js:68:62)
at Generator.next (<anonymous>)
at /var/node/nest-prisma/node_modules/@nestjs/graphql/dist/graphql.factory.js:16:71
at new Promise (<anonymous>)
at __awaiter (/var/node/nest-prisma/node_modules/@nestjs/graphql/dist/graphql.factory.js:12:12)
at GraphQLFactory.mergeOptions (/var/node/nest-prisma/node_modules/@nestjs/graphql/dist/graphql.factory.js:41:16)
(node:6893) 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:6893) [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.
update to "@nestjs/graphql": "6.4.2", still show UnhandledPromiseRejectionWarning: Error: Unknown directive "unique".
I got a similar problem when I try to declare an input with array of string.
be careful that you are not defining a type with incorrect characters, i.e: "user_type" or "user.type". GraphQL only accepts camelCase (UserType) in their definitions. @sangdth If you want to declare an array, try "users: [String!]!".
Thank you, I did not return the array in @field, that was why it yells about that. Added @Field(() => [String])
fixed the problem.
I have the same error than @peterbabic when I run npm run start
I still have this issue:
"dependencies": {
"@nestjs/common": "^6.10.14",
"@nestjs/config": "^0.1.0",
"@nestjs/core": "^6.10.14",
"@nestjs/graphql": "^6.5.3",
"@nestjs/platform-express": "^6.10.14",
"apollo-server-core": "^2.9.16",
"apollo-server-express": "^2.9.16",
"graphql": "^14.6.0",
"graphql-tools": "^4.0.6",
"prisma-binding": "^2.3.16",
"prisma-client-lib": "^1.34.10",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.0",
"rxjs": "^6.5.4",
"type-graphql": "^0.17.6"
}
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.
I'm submitting a...
Current behavior
Expected behavior
Working Nest + Prisma example
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
The sample code does not run on my machine. Related: https://github.com/19majkel94/type-graphql/issues/135
Environment
Bothe environments output the same error, master on 0137ebce0034eada279abae64231789bd11dfbe1