supabase-community / supabase-kt

A Kotlin Multiplatform Client for Supabase.
https://supabase.com/docs/reference/kotlin/introduction
MIT License
424 stars 38 forks source link

[Feature request]: Generate Kotlin types from Database #647

Open iruizmar opened 4 months ago

iruizmar commented 4 months ago

General Info

Feature request

This is a feature present in typescript SDK and it's so useful. We could use KSP for this.

Usecase

No response

jan-tennert commented 4 months ago

So I think calling the API for every build/sync is not a good idea. So maybe we have a separate command/gradle task for retrieving the database types and saving them in a file (JSON or some other file format). Then on the normal builds, the ksp annotation processor reads this data and generates these classes. This would also solve compatibility issues, where database changes are not yet present in the app.

grdsdev commented 4 months ago

I added type generation for Swift a couple of weeks ago, still in beta, https://github.com/supabase/postgres-meta/pull/779 and it isn't as powerful as typescript types, for now, it just generates a plain Swift struct that mimics the DB schema.

jan-tennert commented 4 months ago

I added type generation for Swift a couple of weeks ago, still in beta, https://github.com/supabase/postgres-meta/pull/779 and it isn't as powerful as typescript types, for now, it just generates a plain Swift struct that mimics the DB schema.

Yea, I asked about that on Slack, so I'll look into that too.