Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Resolvers Output file names are undefined for some model names #1690

Open
BilalGumus opened this issue May 13, 2024 · 6 comments
Open
Labels
Bug 🐛 Something isn't working Community 👨‍👧 Something initiated by a community

Comments

@BilalGumus
Copy link

Describe the Bug
When using the npx prisma generate command, file names become undefined for models containing 'Integration' or 'Integrate' in their names at generated/type-graphql/resolvers/outputs/.

To Reproduce

  1. Create a Prisma model with a name containing 'Integration' or 'Integrate'. (e.g. UserIntegration)
  2. Run the npx prisma generate command.
  3. Check the generated resolvers output or export files in the path generated/type-graphql/resolvers/outputs/index.ts.

Expected Behavior
The output files should have properly defined names for models containing 'Integration' or 'Integrate'.

Logs
If you create 2 models models with names containing 'Integration' or 'Integrate', during runtime, typescript throws a "duplicate identifier" error for exports. Otherwise you do not get any error.

Environment (please complete the following information):

  • OS: Windows 11
  • Node v20.12.0
  • Package version 2.0.0-rc.1, 2.0.0-beta.6 (both tested)
  • TypeScript version 5.4.5

Additional Context
This bug seems to affect the generation process under specific circumstances, particularly when model names include certain keywords like 'Integration' or 'Integrate'. Especially if there is more than one model name fitting this scenario, it can lead to issues.

Encountering this issue primarily with specific model names suggests the potential for similar occurrences with other model names.

@MichalLytek MichalLytek added Bug 🐛 Something isn't working Community 👨‍👧 Something initiated by a community labels May 14, 2024
@eduardolundgren
Copy link

I am having the same issue. In my case, the entity name is "Company."

src/graphql/generated/resolvers/outputs/CreateManyApplicationAndReturnOutputType.ts:5:25 - error TS2307: Cannot find module '../outputs/Company' or its corresponding type declarations.

@MichalLytek
Copy link
Owner

Please show a minimal reproducible Prisma schema for this issue

@ankur-arch
Copy link

Hey @MichalLytek you can try with this repo. It has the same issue.

@andreicon
Copy link

andreicon commented May 16, 2024

@MichalLytek I've also submitted an issue in typegraphql-prisma
MichalLytek/typegraphql-prisma#450

According to @jessekrubin s comment and the changelog for the new prisma release, a new, top-level Prisma Client query, createManyAndReturn(), has been implemented.

The result is that the generator will try to create an import for an output type for that resolver from resolvers/outputs/. However that output type file is never generated. I'm assuming that it's similar to the type in models/ and the fix would be to either change the path for the import or write a file in the resolvers/outputs/ dir that exports form models/ but i'm not familiar enough with the code to write the PR myself.

Edit: although the issues seem similar, the timing on is a bit off, @BilalGumus wrote the issue before the 5.14.0 release was out, so his problem might be completely unrelated.

@felippi
Copy link

felippi commented May 29, 2024

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"
    }
  }

@yourbuddyconner
Copy link

If anyone stumbles upon this -- this comment here is what worked for me (I use yarn): MichalLytek/typegraphql-prisma#450 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Something isn't working Community 👨‍👧 Something initiated by a community
Projects
None yet
Development

No branches or pull requests

7 participants