typegraphql-prisma
typegraphql-prisma copied to clipboard
Issue with generating the resolvers in outputs
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
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
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-prismaversion [0.27.2]- Prisma version [5.8.1]
- TypeScript version (5.3.3)
Duplicate of #450?
I have the same issue
CreateMany files are improperly importing the models it seems:
Maybe should be:
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"
}
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.
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"
}