-
-
Notifications
You must be signed in to change notification settings - Fork 398
Add dynamic schemas on a per-query basis #828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the feedback! We do have an issue discussing a solution for this here supabase/postgrest-js#280 . We will pick this one post launch week. Thanks for your patience! |
Thanks @sjones6! We'll need the change both here and in postgrest-js, so keeping this open. |
@soedirgo , updated this PR now that supabase/postgrest-js#455 is published. |
@@ -0,0 +1,201 @@ | |||
export type Json = string | number | boolean | null | { [key: string]: Json } | Json[] | |||
|
|||
export interface Database { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from postgrest-js. Didn't bring over the the whole database setup that postgrest-js has, since that seems like a lot for this change.
Pull Request Test Coverage Report for Build 5778092998Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 5778092998Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Resolves supabase/postgrest-js#280
What kind of change does this PR introduce?
Feature
What is the current behavior?
Currently, the supabase client is created and defaults to the
public
schema when no option is supplied:Or, you can supply an alternative schema:
However, this means that all methods/queries for the client are associated to the single schema. Using multiple schemas requires multiple clients, which presents a challenge for auth where all clients need to be authenticated.
See pre-existing issue:
supabase/postgrest-js#280
What is the new behavior?
Extends on behavior added to underlying
PostgrestClient
: supabase/postgrest-js#455The method added to the supabase client allows for dynamic schema selection on a per-query basis.
If a

Database
generic type is supplied, type inference works as expected without additional generics:Additional context
Add any other context or screenshots.