typegraphql-prisma
typegraphql-prisma copied to clipboard
typescript compile throws errors for prisma version over 5.13.0
Describe the Bug
When compiling project dist with typescript compile, it will throw errors similar to
To Reproduce
Install latest dependencies and generate client and typescript-graphql schema.
Run tsc.
Expected Behavior
tsc compiles successfully
Environment (please complete the following information):
- OS: Ubuntu 24.04
- Node v20.12.2
typegraphql-prisma0.27.2- Prisma 5.14.0
- TypeScript 5.4.5
Additional Context using @prisma/generator-helper and @prisma/internals versions 5.13.0 works
Encountering this as well. createManyAndReturn is new to prisma (https://github.com/prisma/prisma/releases/tag/5.14.0)
Also the new omit could be causing problems (but I do not know).
@andreicon I looked at your PR. locking the generator version(s) seems icky. The problem is that createMany is 1) relatively new to sqlite and 2) now returns the updated data
Just add override on your package.json until the corretion of typegraphql
"overrides": {
"typegraphql-prisma": {
"@prisma/generator-helper": "<=5.13.0",
"@prisma/internals": "<=5.13.0"
}
}
edit: Use npm list @prisma and npm list @prisma/internals to show all dependencies of @prisma, ensure that none of them use @prisma greater than 5.13 Obviously, after that, execute npm install
i'm not sure why @felippi is being downvoted, i did exactly that
i'm not sure why @felippi is being downvoted, i did exactly that
Use *npm list @prisma and npm list @prisma/internals to show all dependencies of @prisma, ensure that none of them use @prisma greater than 5.13 Obviously, after that, execute npm install
@andreicon bc it feels dirty and is not an actual fix as well as it is a fix that must be undone.
@andreicon bc it feels dirty and is not an actual fix as well as it is a fix that must be undone.
I only suggested an alternative that worked for me until the definitive alternative comes, now if these people can afford to have their applications not working until a definitive solution comes, then don't use that and leave your application not working until one appears a clean solution
@felippi a thumbs down is not a personal attack (AFAIK). I support what you're saying!
All the best! Regards, Jesse
Hello @MichalLytek,
Do you have any updates on this issue?
Thanks.
For any Yarn users out there. I chose 5.4.2 because that was the version I previously ran, but obviously any version before 5.14
"resolutions": {
"typegraphql-prisma/@prisma/generator-helper": "5.4.2",
"typegraphql-prisma/@prisma/internals": "5.4.2",
"typegraphql-prisma/@prisma/engines": "5.4.2"
}
For any pnpm-ers out there, the syntax is a little different than npm (as provided in @felippi's answer):
in root package.json
"pnpm": {
"overrides": {
"typegraphql-prisma>@prisma/generator-helper": "<=5.13.0",
"typegraphql-prisma>@prisma/internals": "<=5.13.0"
}
},
Given this schema:
generator client {
provider = "prisma-client-js"
}
generator typegraphql {
provider = "typegraphql-prisma"
output = "../prisma/generated/type-graphql"
emitRedundantTypesInfo = true
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
password String?
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
}
The problem is here: https://github.com/MichalLytek/typegraphql-prisma/blob/be2477654a654f70d87922fd47a2f53ba1b9828f/src/generator/type-class.ts#L48-L54
This does not take in account when the target output type is part of the Model.
{
name: 'author',
args: [],
isNullable: false,
outputType: {
type: 'User',
namespace: 'model',
location: 'outputObjectTypes',
isList: false
},
isRequired: true,
fieldTSType: 'User',
typeGraphQLType: 'User',
argsTypeName: undefined
}
Here is what it usually expects:
{
name: '_max',
args: [],
isNullable: true,
outputType: {
type: 'PostMaxAggregate',
namespace: 'prisma',
location: 'outputObjectTypes',
isList: false
},
isRequired: false,
fieldTSType: 'PostMaxAggregate | null',
typeGraphQLType: 'PostMaxAggregate',
argsTypeName: undefined
}
Edit 2: Bingo! https://github.com/MichalLytek/typegraphql-prisma/blob/be2477654a654f70d87922fd47a2f53ba1b9828f/src/generator/dmmf/types.ts#L50
We forgot to handle for the model case!
It should be fixed in v0.28.0 as the code was adjusted to work with Prisma 5.18 🔒
It should be fixed in
v0.28.0as the code was adjusted to work with Prisma 5.18 🔒
@MichalLytek Thank you!