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

Possibility for local supabase generation #73

Closed Xavier-IV closed 2 months ago

Xavier-IV commented 2 months ago

Supabase can be setup locally, and we can access just the same with remote dashboard using url and anon token, only that we're using 127.0.0.1:54321.

I am able to generate from my remote Supabase, but unfortunately there's connection error when running this locally with such URL:PORT.

This will greatly help with local development before publishing migration to Supabase.

Will this be supported? I'd be happy to support where possible to make this happen.

Screenshot of errors faced:

image
mmvergara commented 2 months ago

@Xavier-IV Hello thanks for opening an issue. I would like to know how did you setup your supabase locally? is it via docker?

Xavier-IV commented 2 months ago

Hi,

Yes, its a combination of docker and supabase-cli: https://supabase.com/docs/guides/cli/getting-started

After the setup (supabase start), in the CLI it will prompt all the necessary credentials (url, anon keys etc). We will also have local Supabase Dashboard we can dig into, although most config are within its config.toml file.

The URL and Anon Keys I've used for both NextJS and Flutter project, they both able to connect to this instance well.

Let me know if you need more info, happy to clarify.

mmvergara commented 2 months ago

Bumped the cli to 1.6.0 can you try updating the cli then generating again?


If it still doesn't work Could you try typing this into your browser? <SUPABASE_URL>/rest/v1/?apikey=<SUPABASE_ANON_KEY>

this will get the raw swagger json if its correct

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


Then also try accessing it without the apikey.

ex: http://127.0.0.1:54321/rest/v1/

Xavier-IV commented 2 months ago

Thanks for getting back.

Yes, I can access the schema from this endpoint: http://127.0.0.1:54321/rest/v1, some screenshot of the JSON for my projects.

image

As for with the anon key, I'm receiving error:

image
Xavier-IV commented 2 months ago

Ah my bad, you've bumped the package. Let me retry again

Xavier-IV commented 2 months ago
image

Yes that works, thank you!

For future reader, command I use:

$ dart pub global run supadart -u http://127.0.0.1:54321 -k <anon_key>

Although the anon key has been rendered unused because of localhost, this is good for me!

mmvergara commented 2 months ago

@Xavier-IV aight great, for context the problem was about the http vs https, supadart is only coded and accounts for https so there's that, and also the instance where the API key isnt required when accessing the swagger json locally, which is what you're seeing in the logs Trying without the API key.

Xavier-IV commented 2 months ago

Awesome, then I believe you can close this ticket if you'd like.

Thanks for the quick implementation!