mmvergara / supadart

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

Generate Models with Supabase Local Env (Docker) #54

Closed karlreginaldo closed 1 month ago

mmvergara commented 1 month ago

@karlreginaldo make the command line access the .env in the project folder to generate the models? Am I understanding this correctly?

karlreginaldo commented 1 month ago

What I mean by local environment is that I want to obtain the generated models while in local development.

Because right now, what’s working is only the Supabase_URL and the anon key that comes directly from the Supabase.com dashboard

Example: supabase_url = http://127.0.0.1:54321 anon_key = xxxxxxxxxxxxxxxxxxxx

mmvergara commented 1 month ago

@karlreginaldo Hmm that's weird... this tool typically works even for local development,

This is an example one for the cli

dart pub global run supadart -u http://localhost:8000 -k eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE

This one is from the website it also works

image

could you provide some logs if the cli is giving some?

karlreginaldo commented 1 month ago

Using supadart cli with yaml image image

D:\Project\Personal\servebeez-mobile\_packages\servebeez_common> supadart supadart.yaml    
🚀 Supadart v1.4.2                                                                            
==============================
URL:        http://127.0.0.1:54321
ANON KEY:   eyJhbGciOiJIUzI1NiIsInR5c...
Output:     lib/generated/models/
Separated:  true
Dart:       false
Mappings:   null
==============================
Generating...
Error Fetching Supabase Swagger
{"code":"PGRST100","details":"unexpected \"e\" expecting \"not\" or operator (eq, gt, ...)","hint":null,"message":"\"failed to parse filter (eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0)\" (line 1, column 1)"}
Failed to fetch database

on the supabase.vercel.app as well it got stuck image image

mmvergara commented 1 month ago

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

also, make sure that they key ur using is in anon_key.

karlreginaldo commented 1 month ago

hmmm this makes sense now. image

karlreginaldo commented 1 month ago

btw i tried removing the apikey queryparams and swagger json showed up

http://127.0.0.1:54321/rest/v1/ image

mmvergara commented 1 month ago

I see the problem now.

You are most likely using the cli for local development (thus the 54321 port) https://supabase.com/docs/guides/cli/getting-started?queryGroups=platform&platform=npx

and not this self hosting docker part. https://supabase.com/docs/guides/self-hosting/docker

and based on the query you made it actually behaves different and doesnt need the apikey..

i guess this tool doesn't support (will work on it) this version of local supabase. what i suggest is probably to just recreate the db in an online version of supabase or switch to docker self hosting in the mean time.

will work on solutions for this though.

karlreginaldo commented 1 month ago

yeah you're right! I'll switch to self hosting.

Thanks @mmvergara. you can close this issue

mmvergara commented 1 month ago

@karlreginaldo

should now support cli type of local development

https://github.com/mmvergara/supadart/pull/57