MichalLytek / typegraphql-prisma

Prisma generator to emit TypeGraphQL types and CRUD resolvers from your Prisma schema
https://prisma.typegraphql.com
MIT License
887 stars 113 forks source link

Multiple `@TypeGraphQL` Comments on a Single Field #400

Closed shellscape closed 7 months ago

shellscape commented 1 year ago

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):

   "type-graphql": "2.0.0-beta.2",
    "typegraphql-prisma": "^0.26.0"

Additional Context

MichalLytek commented 7 months ago

Fixed via 0ab428f 🔒