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

Issue with generating the resolvers in outputs

Open dharmendraboddeda opened this issue 1 year ago • 6 comments

Incorectly generating the rosolvers i have used this same prisma schema at typegraphql-prisma version (0.27.1) but now when use current version 0.27.2 , i am facing the issue generating the resolvers.

generator typegraphql {
  provider           = "typegraphql-prisma"
  output             = "../generated/type-graphql"
  emitTranspiledCode = false
}

To Reproduce 2024-06-06-171042_screenshot

its generating this path

api/generated/type-graphql/resolvers/outputs/CreateManyChatsAndReturnOutputType.ts

and in this return outputType files this kind of modules are not resolving

import { Folder } from "../outputs/Folder";

but previous version that i have used i didn't get generate this files please resolve my issue

Expected Behavior 2024-06-06-171118_screenshot

See i have used typegraphql-prisma: "0.27.1"

Logs

    at _buildSchemaBin (file:///home/dharmendraboddeda/Projects/promanager/conversation-explorer-new/node_modules/@multiplatform.one/typegraphql/lib/chunk-SNLZTJW7.mjs:22:41) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///home/dharmendraboddeda/Projects/promanager/conversation-explorer-new/api/dist/api/main.mjs'
}

Node.js v20.12.1
node:internal/modules/cjs/loader:1146
  throw err;
  ^

Error: Cannot find module '/home/dharmendraboddeda/Projects/promanager/conversation-explorer-new/api/dist/api/main.mjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.12.1
Could not resolve "../outputs/Folder" from "generated/type-graphql/resolvers/outputs/CreateManyChatsAndReturnOutputType.ts"
file: /home/dharmendraboddeda/Projects/promanager/conversation-explorer-new/api/generated/type-graphql/resolvers/outputs/CreateManyChatsAndReturnOutputType.ts

Environment (please complete the following information):

  • OS: debian
  • Node : 20.12.1
  • typegraphql-prisma version [0.27.2]
  • Prisma version [5.8.1]
  • TypeScript version (5.3.3)

dharmendraboddeda avatar Jun 06 '24 13:06 dharmendraboddeda

Duplicate of #450?

MichalLytek avatar Jun 06 '24 13:06 MichalLytek

I have the same issue

Romanchuk avatar Jun 10 '24 05:06 Romanchuk

CreateMany files are improperly importing the models it seems:

image

Maybe should be:

image

savager avatar Jun 11 '24 05:06 savager

image I faced same issue and above change solves the issue, at least runtime error is not showing up after this fix.. this needs to be fixed in code where these imports are autogenerated at package level so that when running 'npm install' generates files with this fix when using below code in schema.prisma file:

generator typegraphql {
  provider           = "typegraphql-prisma"
}

vnamana avatar Jun 13 '24 21:06 vnamana

With the findings of the earlier comments, I added this after my prisma generate step:

find path-of-typegraphql-output/resolvers/outputs -type f -name 'CreateMany*' -exec sed -i 's/\.\.\/outputs\//\.\.\/\.\.\/models\//g' {} \;

Replace path-of-typegraphql-output with the default ./node_modules/@generated/type-graphql, or the output option configured in your prisma schema.

This does the same as what @savager found here: https://github.com/MichalLytek/typegraphql-prisma/issues/454#issuecomment-2159845608

All of my old queries are working, but as I have a read-only database, I can't test the createMany.

RubenNL avatar Jun 20 '24 17:06 RubenNL

Adding this to the package.json seems to be a temporary workaround

"overrides": {
  "@prisma/generator-helper": "^5.4.2 <=5.13.0",
  "@prisma/internals": "^5.4.2 <=5.13.0"
}

the-simian avatar Jun 20 '24 21:06 the-simian