Skip to content
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

feat: generate types on local dev and self-hosted supabase studio #16863

Merged
merged 15 commits into from
Sep 4, 2023

Conversation

kishanhitk
Copy link
Contributor

@kishanhitk kishanhitk commented Aug 26, 2023

What kind of change does this PR introduce?

Feature Addition

What is the current behavior?

Closes: #16793

Allow generating types from local supabase studio.

Additional Info

The type generator in the cloud dashboard generates types only for the public schema. But, the type generated by cli contains the public, storage and graphql_public schema.
I have followed what the cli does because that is what we generally use in the CI pipeline to verify if types are updated.

@vercel
Copy link

vercel bot commented Aug 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2023 6:26am
studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2023 6:26am
studio-self-hosted ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2023 6:26am
studio-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2023 6:26am
zone-www-dot-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2023 6:26am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
ui-storybook ⬜️ Ignored (Inspect) Visit Preview Sep 4, 2023 6:26am

@vercel
Copy link

vercel bot commented Aug 26, 2023

@kishanhitk is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@kishanhitk
Copy link
Contributor Author

I am having some confusion.

When using supabase locally. Clicking on the "Generate and Download types" button makes a call to this URL: http://localhost:8082/api/v1/projects/${projectRef}/types/typescript. But there is no file in the api folder to handle this route.

On cloud supabase dashboard, it makes a call to https://api.supabase.io/v1/projects/${projectRef}/types/typescript, which is working as expected.

There is an API route, http://localhost:8082/api/pg-meta/${projectRef}/types, that can generate types, but I found that even that is not working as expected.

What should be the solution?
Replace the http://localhost:8082/api/v1/projects/${projectRef}/types/typescript with http://localhost:8082/api/pg-meta/${projectRef}/types, and make the http://localhost:8082/api/pg-meta/${projectRef}/types work correctly?

@alaister
Copy link
Member

Hey @kishanhitk,

I think the solution here would be to add an API route for /types/typescript and remove the /types route altogether as it doesn't seem to be used. What do you think?

@kishanhitk
Copy link
Contributor Author

Hey @kishanhitk,

I think the solution here would be to add an API route for /types/typescript and remove the /types route altogether as it doesn't seem to be used. What do you think?

@alaister
But since the URL also has v1 prefix, it requires creating a v1 folder within the api route, as the current api folder does not have any v1 folder.

Why is there a v1? Are we building a new version of API? I see some of the newer features (eg: branches) are using API routes with v1 prefix.
Screenshot 2023-08-29 at 12 12 52 PM

@alaister
Copy link
Member

You can go ahead and create a v1 folder. v1 routes are there because they are publically facing, and so should be versioned :)

@kishanhitk
Copy link
Contributor Author

The type generator in the cloud dashboard generates types only for the public schema. But, the type generated by cli contains the public, storage and graphql_public schema.
I have followed what the cli does because that is what we generally use in the CI pipeline to verify if types are updated.

@kishanhitk kishanhitk marked this pull request as ready for review August 29, 2023 13:40
@kishanhitk kishanhitk requested a review from a team as a code owner August 29, 2023 13:40
@kishanhitk kishanhitk changed the title fix: cannot generate types on local dev and self-hosted feat: generate types on local dev and self-hosted supabase studio Aug 29, 2023
Copy link
Member

@alaister alaister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks, @kishanhitk!

@alaister alaister merged commit bd49f45 into supabase:master Sep 4, 2023
12 of 13 checks passed
@kiwicopple
Copy link
Member

kiwicopple commented Sep 5, 2023

Closes #15502

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Self-hosted Supabase instance cannot generate Typescript types.
3 participants