question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma example code needs explicit types specified for PostsResolver

See original GitHub issue

I’m submitting a…


[ ] 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.

Current behavior

/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/node_modules/type-graphql/dist/helpers/findType.js:17
        throw new errors_1.NoExplicitTypeError(prototype.constructor.name, propertyKey, parameterIndex);
              ^
Error: You need to provide explicit type for PostsResolver#getPosts parameter #0 !
    at Object.findType (/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/node_modules/type-graphql/dist/helpers/findType.js:17:15)
    at Object.getParamInfo (/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/node_modules/type-graphql/dist/helpers/params.js:9:49)
    at Args (/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/node_modules/type-graphql/dist/decorators/Args.js:9:120)
    at Args (/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/node_modules/@nestjs/graphql/dist/decorators/args.decorator.js:27:49)
    at /mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/src/posts/posts.resolver.ts:12:37
    at DecorateProperty (/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/node_modules/reflect-metadata/Reflect.js:553:33)
    at Object.decorate (/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/node_modules/reflect-metadata/Reflect.js:123:24)
    at __decorate (/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/src/posts/posts.resolver.ts:4:92)
    at Object.<anonymous> (/mnt/d/dev/_learn/nest/repo/sample/22-graphql-prisma/src/posts/posts.resolver.ts:20:3)
    at Module._compile (module.js:653:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nest-typescript-starter@1.0.0 start: `ts-node src/main`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nest-typescript-starter@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/delmadord/.npm/_logs/2019-05-13T22_59_07_077Z-debug.log

Expected behavior

Working Nest + Prisma example

Minimal reproduction of the problem with instructions

git clone https://github.com/nestjs/nest.git
cd nest/sample/22-graphql-prisma
npm install
# npm WARN @nestjs/graphql@6.0.5 requires a peer of type-graphql@^0.17.0 but none is installed. You must install peer dependencies yourself.
npm install --save type-graphql@^0.17.0
npm run build
npm run start

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

  • Windows node v8.10.0
  • WSL Bash node v8.16.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
brainsbucketcommented, Jun 6, 2019

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.
2reactions
kamilmysliwieccommented, Jun 6, 2019

Update your packages to the latest @nestjs/graphql

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Guide to Common Resolver Patterns - Prisma Tutorials
This tutorial gives an overview about common scenarios you might encounter when implementing your GraphQL server with graphql-yoga and Prisma.
Read more >
Advanced type safety (Reference) - Prisma
The generated code for Prisma Client contains several helpful types and utilities that you can use to make your application more type-safe.
Read more >
Upgrading from Prisma 1 with prisma-binding to SDL-first
Overview. This upgrade guide describes how to migrate a Node.js project that's based on Prisma 1 and uses prisma-binding to implement a GraphQL...
Read more >
Operating against partial structures of your model types - Prisma
This page documents various scenarios for using the generated types from the Prisma ... For example, assume you have the following User and...
Read more >
Prisma schema API (Reference)
Examples. Specify a PostgreSQL data source. In this example, the target ... When running a Prisma CLI command that needs the database connection...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found