prisma-examples icon indicating copy to clipboard operation
prisma-examples copied to clipboard

Run example graphql-nestjs /graphql error 404

Open nicostubi opened this issue 3 years ago • 0 comments

Bug description

Hello,

I've followed the doc to setup this typescript project:

https://github.com/prisma/prisma-examples/tree/latest/typescript/graphql-nestjs#2-start-the-graphql-server

When I run the server, and browse: http://localhost:3000/ I can see the blog up and running When I browse http://localhost:3000/ as suggested by the doc:

image

I get the following debug logs:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.env
  next:jsconfig-paths-plugin tsconfig.json or jsconfig.json paths: {} +0ms
  next:jsconfig-paths-plugin resolved baseUrl: C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs +1ms
  next:jsconfig-paths-plugin tsconfig.json or jsconfig.json paths: {} +7ms
  next:jsconfig-paths-plugin resolved baseUrl: C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs +0ms
  next:jsconfig-paths-plugin tsconfig.json or jsconfig.json paths: {} +5ms
  next:jsconfig-paths-plugin resolved baseUrl: C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs +0ms
  next:jsconfig-paths-plugin paths are empty, bailing out +2s
  next:jsconfig-paths-plugin paths are empty, bailing out +1ms
  next:jsconfig-paths-plugin paths are empty, bailing out +1ms
  next:jsconfig-paths-plugin paths are empty, bailing out +1ms
event - compiled client and server successfully in 1741 ms (396 modules)
wait  - compiling /_error (client and server)...
event - compiled client and server successfully in 125 ms (397 modules)
  compression gzip compression +0ms
  send allow dotfile "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\webpack.js" +0ms
  send stat "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\webpack.js" +0ms
  send allow dotfile "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\main.js" +0ms
  send stat "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\main.js" +0ms
  send allow dotfile "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\react-refresh.js" +1ms
  send stat "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\react-refresh.js" +1ms
  send pipe "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\webpack.js" +0ms
  send accept ranges +0ms
  send modified Wed, 09 Nov 2022 10:28:07 GMT +0ms
  send etag W/"c349-1845beecb1c" +1ms
  send content-type application/javascript +0ms
  send pipe "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\main.js" +1ms
  send accept ranges +0ms
  send modified Wed, 09 Nov 2022 10:28:02 GMT +0ms
  send etag W/"470716-1845beebb0d" +0ms
  send content-type application/javascript +0ms
  send allow dotfile "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\pages\_app.js" +1ms
  send stat "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\pages\_app.js" +0ms
  send allow dotfile "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\development\_buildManifest.js" +1ms
  send stat "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\development\_buildManifest.js" +0ms
  send pipe "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\react-refresh.js" +0ms
  send accept ranges +1ms
  send modified Wed, 09 Nov 2022 10:28:02 GMT +0ms
  send etag W/"12d39-1845beebb0d" +0ms
  send content-type application/javascript +0ms
  send pipe "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\pages\_app.js" +1ms
  send accept ranges +0ms
  send modified Wed, 09 Nov 2022 10:28:02 GMT +0ms
  send etag W/"32629b-1845beebb13" +1ms
  send content-type application/javascript +0ms
  send pipe "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\development\_buildManifest.js" +1ms
  send accept ranges +0ms
  send modified Wed, 09 Nov 2022 10:28:07 GMT +1ms
  send etag W/"eb-1845beecb1c" +0ms
  send content-type application/javascript +0ms
  compression gzip compression +28ms
  compression gzip compression +1ms
  compression gzip compression +0ms
  compression gzip compression +1ms
  compression no compression: size below threshold +0ms
  send allow dotfile "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\pages\_error.js" +7ms
  send stat "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\pages\_error.js" +1ms
  send pipe "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\chunks\pages\_error.js" +1ms
  send accept ranges +0ms
  send modified Wed, 09 Nov 2022 10:28:02 GMT +0ms
  send etag W/"d40-1845beebb0c" +0ms
  send content-type application/javascript +0ms
  send allow dotfile "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\development\_ssgManifest.js" +1ms
  send stat "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\development\_ssgManifest.js" +0ms
  send pipe "C:\Projects\Github\My Repositories\prisma-examples\typescript\graphql-nextjs\.next\static\development\_ssgManifest.js" +1ms
  send accept ranges +0ms
  send modified Wed, 09 Nov 2022 10:28:07 GMT +0ms
  send etag W/"4c-1845beecb1c" +1ms
  send content-type application/javascript +0ms
  compression gzip compression +10ms
  compression no compression: size below threshold +1ms
  compression no compression: size below threshold +214ms

Also, another question. When I send a query with a wrong field, I get this payload for the error. I was looking for a best practice here, and I'm wondering if it is the way to go (e.g. display the full stack trace is probably not a good practice, huh?)

{
  "errors": [
    {
      "message": "Cannot query field \"id2\" on type \"Post\". Did you mean \"id\"?",
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED",
        "exception": {
          "stacktrace": [
            "GraphQLError: Cannot query field \"id2\" on type \"Post\". Did you mean \"id\"?",
            "    at Object.Field (C:\\Projects\\Github\\My Repositories\\prisma-examples\\typescript\\graphql-nextjs\\node_modules\\graphql\\validation\\rules\\FieldsOnCorrectTypeRule.js:51:13)",
            "    at Object.enter (C:\\Projects\\Github\\My Repositories\\prisma-examples\\typescript\\graphql-nextjs\\node_modules\\graphql\\language\\visitor.js:301:32)",
            "    at Object.enter (C:\\Projects\\Github\\My Repositories\\prisma-examples\\typescript\\graphql-Best nextjs\\node_modules\\graphql\\utilities\\TypeInfo.js:391:27)",
            "    at visit (C:\\Projects\\Github\\My Repositories\\prisma-examples\\typescript\\graphql-nextjs\\node_modules\\graphql\\language\\visitor.js:197:21)",
            "    at validate (C:\\Projects\\Github\\My Repositories\\prisma-examples\\typescript\\graphql-nextjs\\node_modules\\graphql\\validation\\validate.js:91:24)",
            "    at validate (C:\\Projects\\Github\\My Repositories\\prisma-examples\\typescript\\graphql-nextjs\\node_modules\\apollo-server-core\\dist\\requestPipeline.js:186:39)",
            "    at processGraphQLRequest (C:\\Projects\\Github\\My Repositories\\prisma-examples\\typescript\\graphql-nextjs\\node_modules\\apollo-server-core\\dist\\requestPipeline.js:98:34)",
            "    at runMicrotasks (<anonymous>)",
            "    at processTicksAndRejections (node:internal/process/task_queues:96:5)",
            "    at async processHTTPRequest (C:\\Projects\\Github\\My Repositories\\prisma-examples\\typescript\\graphql-nextjs\\node_modules\\apollo-server-core\\dist\\runHttpQuery.js:221:30)"
          ]
        }
      }
    }
  ]
}

Best Regards, Nicolas

How to reproduce

follow the getting start until display the graphql playground in the browser: https://github.com/prisma/prisma-examples/tree/latest/typescript/graphql-nestjs#2-start-the-graphql-server

Expected behavior

display a playground

Prisma information

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

model User {
  email String  @unique
  id    Int     @default(autoincrement()) @id
  name  String?
  posts Post[]
}

model Post {
  authorId  Int?
  content   String?
  id        Int     @default(autoincrement()) @id
  published Boolean @default(false)
  title     String
  author    User?   @relation(fields: [authorId], references: [id])
}

Environment & setup

  • OS: Windows 11
  • Database: SQLite
  • Node.js version: 16.17.0

Prisma Version

image

nicostubi avatar Nov 09 '22 10:11 nicostubi