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

Make it possible to select schemas #88

Closed vad-bal closed 1 month ago

vad-bal commented 1 month ago

Hi

I think it would be a really useful feature to be able to select different schemas to generate classes for.

There could be an option in the config like schemas: with the default value of public to keep it compatible. Also, the mappings would need to updated to specify schema of the mapped table.

Here is an example how a valid config could look like:

schemas:
  - public
  - myschema
mappings:
  public.items: Item
  public.mytable: MyClass
  myschema.mytable: MyOtherClass

Of course when selecting a single schema, the mapping keys can be the same as before.

mmvergara commented 1 month ago

Hi, thanks for opening an issue, so basically we wan't to able to generate class from other schema other than public.

This package actually relies on this rest api endpoint:

<SUPABASE_URL>/rest/v1/?apikey=<SUPABASE_ANON_KEY>

ex.

http://localhost:8000/rest/v1/?
apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE

to get the swagger json and generate class from it.

i tried creating a new schema and a new table from that schema but we can't actually access those using that endpoint as it only gets the public schema. "title":"standard public schema","version":"12.2.3 (519615d)"

Id love to implement this feature but as far as I'm concerned we can't access those. unless there is another way.

vad-bal commented 1 month ago

Okay, I get it.

Actually I made few searches since your reply. And it looks like it's possible to generate apis for different schemas, using javascript on the server side. Then in theory one could create another config file for the new endpoint url.

So it looks like to me that this issue is not in the scope of this project.

I'm closing it. Thanks for the quick reply.

mmvergara commented 1 month ago

will explore this further, I would be glad if could provide the resources on how to that.