steebchen / prisma-client-go

Prisma Client Go is an auto-generated and fully type-safe database client
https://goprisma.org
Apache License 2.0
2.1k stars 94 forks source link

Generating the js client with the Go client doesn't work #455

Open matthewmueller opened 3 years ago

matthewmueller commented 3 years ago

Right now you get a rather unusual error if you have provider = "prisma-client-js". Tried generating a new Go client:

$ go run github.com/prisma/prisma-client-go generate
info: 2021/04/07 15:25:31 prisma cli doesn't exist, fetching... (this might take a few minutes)
info: 2021/04/07 15:26:07 prisma cli fetched successfully.
Prisma schema loaded from schema.prisma
Error: Generator at /Users/m/dev/src/github.com/prisma/homepage-v8/node_modules/@prisma/client/generator-build/index.js could not start:

internal/modules/cjs/loader.js:967
  throw err;
  ^
Error: Cannot find module '/Users/m/dev/src/github.com/prisma/homepage-v8/ui/explore/--max-old-space-size=8096'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:964:15)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1346:46)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Function.Module.runMain (pkg/prelude/bootstrap.js:1375:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

panic: could not run [generate]: exit status 1

goroutine 1 [running]:
main.main()
        /Users/m/dev/pkg/mod/github.com/prisma/prisma-client-go@v0.7.0/main.go:29 +0x49b
exit status 2

My schema looks like this:

// This is your Prisma schema file. Learn more in the
// documentation: https://pris.ly/d/prisma-schema

datasource db {
  provider = "postgres"
  url      = env("DATABASE_URL")
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["createMany", "groupBy", "orderByRelation"]
}

model User {
  id        Int      @id @default(autoincrement())
}
$ go run github.com/prisma/prisma-client-go version 
prisma               : 2.18.0
@prisma/client       : 2.19.0
Current platform     : darwin
Query Engine         : query-engine da6fafb57b24e0b61ca20960c64e2d41f9e8cff1 (at ../../../../../../../Library/Caches/prisma/binaries/cli/2.18.0/da6fafb57b24e0b61ca20960c64e2d41f9e8cff1/prisma-query-engine-darwin, resolved by PRISMA_QUERY_ENGINE_BINARY)
Migration Engine     : migration-engine-cli da6fafb57b24e0b61ca20960c64e2d41f9e8cff1 (at ../../../../../../../Library/Caches/prisma/binaries/cli/2.18.0/da6fafb57b24e0b61ca20960c64e2d41f9e8cff1/prisma-migration-engine-darwin, resolved by PRISMA_MIGRATION_ENGINE_BINARY)
Introspection Engine : introspection-core da6fafb57b24e0b61ca20960c64e2d41f9e8cff1 (at ../../../../../../../Library/Caches/prisma/binaries/cli/2.18.0/da6fafb57b24e0b61ca20960c64e2d41f9e8cff1/prisma-introspection-engine-darwin, resolved by PRISMA_INTROSPECTION_ENGINE_BINARY)
Format Binary        : prisma-fmt da6fafb57b24e0b61ca20960c64e2d41f9e8cff1 (at ../../../../../../../Library/Caches/prisma/binaries/cli/2.18.0/da6fafb57b24e0b61ca20960c64e2d41f9e8cff1/prisma-prisma-fmt-darwin, resolved by PRISMA_FMT_BINARY)
Studio               : 0.356.0
matthewmueller commented 3 years ago

Figured it out,

generator client {
-  provider = "prisma-client-js"
+  provider = "go run github.com/prisma/prisma-client-go" 
  previewFeatures = ["createMany", "groupBy", "orderByRelation"]
}

Maybe we can improve the error message?

garrensmith commented 2 years ago

The go client is no longer supported.

janpio commented 2 years ago

That unfortunately doesn't change anything about the weirdness about the error message from the generator.

@matthewmueller Do I understand correctly that basically trying to generate a normal JS Client via the Go CLI leads to this unhelpful error message?

steebchen commented 1 year ago

Do I understand correctly that basically trying to generate a normal JS Client via the Go CLI leads to this unhelpful error message?

Correct

steebchen commented 1 year ago

Needs to be fixed by Prisma core via https://github.com/prisma/prisma/issues/10564