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

Creating typed Client from supabase openapi schema #584

Closed
NixBiks opened this issue Oct 9, 2023 · 4 comments
Closed

Creating typed Client from supabase openapi schema #584

NixBiks opened this issue Oct 9, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@NixBiks
Copy link

NixBiks commented Oct 9, 2023

Is your feature request related to a problem? Please describe.

Currently the python client isn't typed based on the data model. It makes a bit "wild wild west". Using the generated OpenAPI schema it should be possible to generate a typed blient.

Describe the solution you'd like

I think it would be great to have similar support in Python as there is in Typescript currently. On the Typescript side of things, it is possible to generate a typed Client

Additional context
It might be useful to get some inspiration from openapi-python-client

@anand2312
Copy link
Contributor

Related: supabase-community/postgrest-py#301

This feature has been on my mind for sometime, but the DX won't be as good as it is with typescript just due to limitations of the Python type system (for example, selecting only a few columns would be almost impossible to reflect in the returned type)
It'd still be very useful to have this.

@anand2312 anand2312 added the enhancement New feature or request label Oct 9, 2023
@NixBiks
Copy link
Author

NixBiks commented Oct 9, 2023

Ah yeah that's true. Typescript is definitely more powerful than the Python type system. Didn't think of all those dynamic select statements.

@NixBiks
Copy link
Author

NixBiks commented Nov 18, 2023

I went with a different solution for my use case. Since python runs server side then connecting directly to the database is often a viable solution (instead of using postgrest api).

So I went with Prisma Client Python. Ie. I used Prisma CLI to generate prisma.schema based on the existing database. Then I generated my prisma python client from the schema. And voila you have a fully typed python client to interact with your database.

It's probably a different scope than the scope of supabase-py but it would still be useful for a similar supabase python solution. I'm stating it here if others are looking for a fully typed solution as well and for possible inspiration for supabase-py too.

@silentworks
Copy link
Contributor

This is currently a nice to have but outside the scope of this project at the moment. Solution mention by NixBiks can be used if types are absolutely necessary for your project.

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

No branches or pull requests

3 participants