-
-
Notifications
You must be signed in to change notification settings - Fork 902
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
[Chore] Refactor Lemmy API common to avoid exposing structs directly from DB #5457
Comments
So you mean adding |
api common already has a uuid feature flag that you should be able to turn off. It looks like we just also need to make that a feature flag for db_schema.
It also looks like that's only being used for the captcha_answer. That should just be made into a string anyway. |
That would require a db migration because |
Yep. Looks like there's only two uuid columns, in the captcha table, and the jwt_secret. We'd need to alter the columns, then use postgres' https://hatchjs.com/postgres-cast-uuid-to-string/ Its up to @SleeplessOne1917 if that's worth necessary. Ideally wasm should just support UUID. |
Starting to work on this. Is there a command that needs to be run to generate a migration? The migration folders look like they were named programmatically. Also,
Currently UUID can be used with WASM, but it can only be enabled if either the |
Do those add a lot of bulk? UUID seems like a basic enough thing for a front end to have anyway. uuid-rs/uuid#350 (comment) |
UUID itself doesn't, however refactoring the code so that we can use what are basically just API models without pulling in any of the DB stuff proved to be a much more difficult and labor-intensive refactor than I anticipated. It would be nice to be able to use all of the API types without having a peer dependency on
In this case, the difficulty come from direct use of a struct meant to be used in the data layer of the backend application. This issue explains the problem. Essentially, recent versions of I'll see if there's a way to tweak the dependencies to make it so things don't break when targetting WASM. A big part of the issue is that |
Requirements
Is your proposal related to a problem?
Working on the rust client and leptos UI, I noticed that several types are pulled directly from the re-exported
lemmy_db_schema
crate. At the very least, it would be good to re-export them in relevant modules inlemmy_api_common
instead.More importantly, if
lemmy_api_common
is only meant to be types of requests, responses, and shapes used in them, them it is important that we don't leak too much funtionality from the rest of the app through this library. This has become a problem working on the leptos UI: the dependency onuuid
is leaking through, and a recent update to uuid is causing compilation to fail when targetting WASM, even when using the crate at version 0.19.8.Describe the solution you'd like.
Refactor
lemmy_api_common
to expose as little logic (and as few dependencies) to downstream projects as possible.Describe alternatives you've considered.
Add a config gate to
lemmy_db_schema
's Cargo.toml to make theuuid
dependency use a valid source of randomness when targetting WASM. I'm not a fan of this idea, as I really don't think a crate used for the app's database that is solely used in the server should need to worry about WASM support.Make a new crate (
lemmy_models
or something to that effect) with the barest information available and tell people to use that instead oflemmy_api_common
.Additional context
No response
The text was updated successfully, but these errors were encountered: