deptyped / prisma-extension-pagination

Prisma Client extension for pagination
https://npmjs.com/prisma-extension-pagination
MIT License
227 stars 17 forks source link

Not compatible with Prisma v5 #11

Closed jaaneh closed 1 year ago

jaaneh commented 1 year ago

Hey, trying to get this working with v5 and saw #10 was merged. However, it doesn't seem to be functional with this still.

Prisma v4.16.2 works fine with no errors.

Prisma v5.0.0: image

Here's my prisma setup

import { PrismaClient } from "@prisma/client"
import pagination from "prisma-extension-pagination"

const prismaClient = new PrismaClient()
const prisma = prismaClient.$extends(pagination)

export default prisma
jaaneh commented 1 year ago

Actually, using a setup like this seems to work, but adding it to all models is causing issues.

import { PrismaClient } from "@prisma/client"
import { paginate } from "prisma-extension-pagination"

const prismaClient = new PrismaClient()
const prisma = prismaClient.$extends({
  model: {
    book: {
      paginate
    }
  }
})

export default prisma
jaaneh commented 1 year ago

Also going to hijack my own issue to ask if it's possible to add config globally. For example, I want to add includePageCount: true as default to all responses, and instead disable it for the few where I may not want it.

deptyped commented 1 year ago

Hi, it looks like a problem with module resolution. Can you provide your tsconfig?

Also going to hijack my own issue to ask if it's possible to add config globally. For example, I want to add includePageCount: true as default to all responses, and instead disable it for the few where I may not want it.

No, this is not implemented yet.

jaaneh commented 1 year ago

Hi, it looks like a problem with module resolution. Can you provide your tsconfig?

Sure. Here you are

{
  "compilerOptions": {
    "module": "commonjs",
    "allowSyntheticDefaultImports": true,
    "target": "esnext",
    "noImplicitAny": true,
    "esModuleInterop": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "sourceMap": true,
    "outDir": "dist",
    "baseUrl": "src",
    "strict": true,
    "typeRoots": ["types"]
  },
  "include": ["src/**/*", "types"],
  "exclude": ["node_modules"]
}
deptyped commented 1 year ago

@jaaneh Can you test version 0.4.1? Should be fixed now

jaaneh commented 1 year ago

Can you test version 0.4.1? Should be fixed now

Unfortunately looks like it's still an issue. I'm extending all to get around it for now.

import { PrismaClient } from "@prisma/client"
import { paginate } from "prisma-extension-pagination"

const prisma = new PrismaClient().$extends({
  model: {
    $allModels: {
      paginate
    }
  }
})
deptyped commented 1 year ago

@jaaneh Can you test 0.4.2?

If still not working please check this minimal reproducible example, works for me https://github.com/deptyped/prisma-extension-pagination-issue-11

jaaneh commented 1 year ago

@jaaneh Can you test 0.4.2?

0.4.2 works! 🎉 Thank you for fixing so quickly.