nuxt-modules / supabase

Supabase module for Nuxt.
https://supabase.nuxtjs.org
MIT License
733 stars 129 forks source link

Add support for database types on different schemas. #392

Open dts opened 4 months ago

dts commented 4 months ago

This plumbs through a config-set schema name to the types system.

Types of changes

Description

Currently, types do not correctly reflect overridden schemas. This PR allows that schema to be plumbed through reasonably.

Checklist:

netlify[bot] commented 4 months ago

Deploy request for n3-supabase pending review.

Visit the deploys page to approve it

Name Link
Latest commit b6e0beaab9dc80e90fbc1c76a73056c932aad848
IsraelOrtuno commented 3 months ago

There's a problem with this at the moment as it seems that the types imports (here) in the composables are being wiped out when running the build command:

dist/runtime/composables/useSupabaseClient.d.ts

import type { SupabaseClient } from '@supabase/supabase-js';
export declare const useSupabaseClient: <T = unknown, S extends string & keyof T = Schema>() => SupabaseClient<T, S>;

https://github.com/nuxt-modules/supabase/issues/383#issuecomment-2236104268

For me this only works when running in the playground folder as the build is prepared using --stub, which doesn't remove any import.

If you want to reproduce just run pnpm run build and check dist/runtime/composables/useSupabaseClient.d.ts. You will see that import type { Database, Schema } from '#build/types/supabase-database' will be gone.

I am still figuring out how to fix this.

larbish commented 2 months ago

@dts @IsraelOrtuno Could you have a check now that https://github.com/nuxt-modules/supabase/pull/404 has been merged?

IsraelOrtuno commented 1 month ago

This fixed the issues with my PR so I would say it should work now @dts