feat: automatically pass database typings to clients#366
Merged
Conversation
✅ Deploy Preview for n3-supabase canceled.
|
|
Looking forward to merging :) |
larbish
approved these changes
Jul 5, 2024
larbish
left a comment
Member
There was a problem hiding this comment.
Thanks a lot for the PR @IsraelOrtuno. I was waiting for an upstream fix to merge this big PR and merge all other fixes and features. That's why it took time to merge 🙏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 Databaseto 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 = unknownso 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: