MichalLytek / typegraphql-prisma

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

`view` models with underscores aren't case converted #373

Closed shellscape closed 1 year ago

shellscape commented 1 year ago

Describe the Bug

I'm using the prisma preview views feature. I have a view defined as such:

view item_snapshot {
...
}

This package then generates resolvers that look like aggregateItem_snapshots and types like that look like Item_snapshot

To Reproduce A quick guide how to reproduce the bug. You can paste here code snippets or even better, provide a link to the repository with minimal reproducible code example.

Expected Behavior

Resolvers that look like aggregateItemSnapshots are generated along with a ItemSnapshot type

Logs

unsure if needed

Environment (please complete the following information):

Additional Context

The same goes for field names like created_at and updated_at. Most of the graphql generating tools I've used over the years take care of this conversion for you. Was surprised to find that wasn't the case here.

MichalLytek commented 1 year ago

This reflects to all model and types, not only views. And Prisma Client also does not change the names. So I don't plan to change the behavior.

If you want clean names, just use PascalCase and @@map directive in Prisma schema.

shellscape commented 1 year ago

it doesn't look like youre familiar with the new views support. views are equivalent to models for generation. I believe you closed this prematurely

MichalLytek commented 1 year ago

Your issue with "wrong" names for types for views occurs also for models and mongo nested types. Just test it by creating a model foo_bar_baz and see how the Prisma Client looks like prisma.foo_bar_baz.findMany().

shellscape commented 1 year ago

you know what, I thought I was responding to a different issue lol. that's what I get for looking at the phone first thing out of bed..