MichalLytek / typegraphql-prisma

Prisma generator to emit TypeGraphQL types and CRUD resolvers from your Prisma schema

Home Page:https://prisma.typegraphql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple `@TypeGraphQL` Comments on a Single Field

shellscape opened this issue · comments

Describe the Bug

It doesn't appear to be possible to add multiple @TypeGraphQL comments to a single field. I have the need to specify a field as a different type, as well as exclude it from output.

To Reproduce

Attempt 1:

view users {
  /// @TypeGraphQL.field(type: "ID") @TypeGraphQL.omit(input: true)
  organization_id      String @unique
}

But this results in an obscure JSON error with a failed generate:

Error: 
✔ Generated Prisma Client (4.16.2 | library) to ./node_modules/@codegen/read in 101ms

Unexpected token ) in JSON at position 4

Attempt 2:

view users {
  /// @TypeGraphQL.field(type: "ID")
  /// @TypeGraphQL.omit(input: true)
  organization_id      String @unique
}

But this results in the field type comment being ignored and a comment being inserted into the schema (note that it's not an ID type):

  "\n@TypeGraphQL.omit(input: true)"
  organizationId: String!

Expected Behavior

organizationId: ID! in the model type, and organizationId not appears in input types.

Logs
If applicable, add some console logs to help explain your problem.
You can paste the errors with stack trace that were printed when the error occurred.

Environment (please complete the following information):

  • OS: [e.g. Windows 10 21H1] Mac OSX
  • Node (e.g. 15.8.0) v18.15.0
  • typegraphql-prisma version [e.g. 0.11.1] (please check if the bug still exist in newest release)
   "type-graphql": "2.0.0-beta.2",
    "typegraphql-prisma": "^0.26.0"
  • Prisma version [e.g. 2.18.0] v4.16.2
  • TypeScript version (e.g. 4.2.2) v5.0.4

Additional Context