mmvergara / supadart

Typesafe queries in Supabase Flutter! Generate Flutter / Dart 🎯 classes from your Supabase schema.
https://supadart.vercel.app
MIT License
43 stars 5 forks source link

Suggested type safe api #95

Closed North101 closed 1 month ago

North101 commented 1 month ago

I think Supadart could generate better type safe code by creating a wrapper for Supabase instead of adding to it.

current:

supabase.my_table
  .select()
  .eq(MyTable.c_id, id)
  .single()
  .withConverter(MyTable.converterSingle);

supabase.my_table
  .stream(primaryKeys: [MyTable.c_id])
  .eq(MyTable.c_id, id)
  .map(MyTable.converter);

suggested:

supadart(supabase).myTable
  .select([
    MyTable.c.id, // only allows table columns
  ])
  .where(MyTable.c.id.eq(id)) // type safe filtering
  .single()
  ;// no need to apply a converter

supadart(supabase).myTable
  .stream // primary keys are known to supadart so no need to manually supply them
  .where(MyTable.c.id.eq(id)) // type safe filtering
  ;// no need to apply a converter
mmvergara commented 1 month ago

Hey, thanks for opening an issue. I like the idea first of all and given it some thought and sample implementations. I've shared it with some of my flutter friends.

They said that the idea was something but probably not going to use it since the normal sdk way is the one they are used to and is really just enough for them. It changed how i think about it, supadart was designed just to add typesafe'ish since its really just the one missing compare to the js sdk. Thanks for suggesting but i think we just stick as much to the vanilla way.

North101 commented 1 month ago

Understood. I can also see it being a lot more complex to implement. I might try implementing it myself