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

can cornucopia work with rust frontend framework, like Leptos? #238

Open
yingweixiang opened this issue Mar 10, 2024 · 2 comments
Open

can cornucopia work with rust frontend framework, like Leptos? #238

yingweixiang opened this issue Mar 10, 2024 · 2 comments

Comments

@yingweixiang
Copy link

It would be great to show the query result on the webpage.
like use Loptos to build a web UI and show the result in a table, like leptos-struct-table.

Hope there will be a simple demo to make cornucopia and Leptos work together.

@blowback
Copy link

blowback commented Mar 24, 2024

It can work with leptos fine, but it is not entirely frictionless in SSR mode: you have to define all the query types twice, once for the backend (these types are generated by cornucopia) and once for the front-end (manually re-define all the types you're interested in).

You can't currently use cornucopia's generated types in the front-end directly because of all the additional dependencies on futures, GenericClient, tokio_postgres etc. which will break the front-end build with the dreaded slew of mio errors.

As an alternative to WET, you could maybe write a macro to extract the front-end types, but that would be quite brittle to cornucopia changes.

My strategy is to wait for PR#211 to land and hope that in its final form I can use the types from that (not possible in its current state).

Seems like this is no different from sqlx with leptos: in leptos-heavy-metal-stack you can see where Todo is declared twice (lines 22, 29).

@yingweixiang
Copy link
Author

Thanks for your comment. That's very helpful.

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

No branches or pull requests

2 participants