feat: automatically pass database typings to clients #366
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Types of changes
Description
This PR aims to automatically pass Supabase database generated types to the clients to get autocompletion and type-safe results when querying the database. By default it will try to locate the database typings
~/types/database.types.ts
.This can be configured:
Types could be overwritten too:
What it does under the hood is to basically map
type Database
to what is found in that file (if exists) as this type is always passed to the clients. If not, it will generate a defaulttype Database = unknown
so the clients still get a type. It's my first working with auto-generated TypeScript so not sure if it's the way to go but works pretty nice. Open to any suggestions of how this should be made.Resolves what motivated @ozum to submit this PR #160 and also this issue #150
Checklist: