arthurfiorette / prisma-json-types-generator

⚒️ Changes JsonValues to your custom typescript type.
https://npm.im/prisma-json-types-generator
MIT License
375 stars 22 forks source link

Add support for TypedSQL queries. #398

Open gausie opened 3 days ago

gausie commented 3 days ago

Prerequisites

Versions

Prisma 5.20.0 prisma-json-types-generator 3.1.1

Description

A query written with Prisma's new TypedSQL returns JsonValue as normal for a column that has been typed with this package.

Steps to Reproduce

Write a TypedSQL query that returns a Json field. Observe that it is typed as JsonValue

Expected Behavior

It should be typed according to the triple slash comment in schema.prisma

arthurfiorette commented 3 days ago

Hi @gausie, thanks for opening this feature request, would you like to work on it? remember to add unit tests...

arthurfiorette commented 3 days ago

I'm not even sure how is the plugin system working for TypedSQL...

gausie commented 2 days ago

Yeah nor do I. I will gladly give it a go though

gausie commented 2 days ago

Had a little look into doing it - generating types with --sql relies on introspection via the schema engine, so it doesn't fit well into the current approach to testing. We could look at using something like pgmock to provide a valid url for the db provider... but that's a big change. What do you think?

arthurfiorette commented 2 days ago

I think it will be easier to just spin up a docker postgres via docker compose and test using that db/schema.

gausie commented 2 days ago

How would you want to do that in CI?

arthurfiorette commented 2 days ago

https://docs.github.com/en/actions/use-cases-and-examples/using-containerized-services/creating-postgresql-service-containers

gausie commented 2 days ago

Fair enough!