paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
687 stars 55 forks source link

TypeError: The "to" argument must be of type string. Received an instance of Object. Code: `ERR_INVALID_ARG_TYPE` #332

Closed eunchurn closed 4 months ago

eunchurn commented 4 months ago

Steps of reproduce

  1. Installation by using @paljs/cli create
npx @paljs/cli create

image

yarn install
  1. Generating
image
yarn run v1.22.22
$ pal g && npm -s run generate:prisma && npm -s run generate:nexus
    TypeError: The "to" argument must be of type string. Received an instance of Object
    Code: ERR_INVALID_ARG_TYPE
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What did I do wrong?

Tested Node Versions: v22.2.0, v20.13.1

eunchurn commented 4 months ago

https://github.com/paljs/prisma-tools/blob/39ea091ee8e0cd4d0014de1e7cbbd7a7cd41313e/packages/utils/src/dmmf.ts#L21

I found the cause. The schemaPath is nested in the form of schemaPath.schemaPath here. The nested schemaPath.schemaPath appears as an absolute path. Therefore, the issue arises because path.relative() receives to in an object format. Consequently, on line 8, you need to change const schemaPath = await getSchemaPath0(path); to const { schemaPath } = await getSchemaPath0(path);.

eunchurn commented 4 months ago

The above issue appears to stem from the @prisma/internals version. It seems that fixing the @prisma/internals package to version 5.2.0 instead of using ^5.2.0 will resolve this issue.

if you are using pnpm, add package.json as follow

{
  "pnpm": {
    "overrides": {
      "@prisma/internals": "5.2.0"
    }
  }
}
AhmedElywa commented 4 months ago

Fixed in the last version, We upgraded the Prisma version to 5.14