-
Notifications
You must be signed in to change notification settings - Fork 11
feat: Experimental dioxus fullstack support #46
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
base: main
Are you sure you want to change the base?
Conversation
|
@marc2332 just had a go with this, but the use_server_query somehow never returns (just keeps blocking while page loading). |
So, in other words the suspense does not get "resolved" in the server side? Can you share how you call |
|
I don't have a minimal example (yet), but I call it something like this: #[component]
fn Foobar(id: ReadOnlySignal<Uuid>) -> Element {
let foobar_query = use_server_query(Query::new(id(), GetFoobar())).suspend()?;
// …
}
#[derive(Clone, PartialEq, Hash, Eq)]
struct GetFoobar();
impl QueryCapability for GetFoobar {
type Ok = String;
type Err = String;
type Keys = Uuid;
async fn run(&self, id: &Self::Keys) -> Result<Self::Ok, Self::Err> {
let foobar = load_foobar(id).await; // this calls the server function
Ok(foobar)
}
} |
Can you try with the last commit I pushed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces experimental dioxus fullstack support to the query library, enabling server-side query caching and serialization between client and server. It adds new features for web and server environments that allow queries to be executed and cached on the server, then serialized and sent to the client.
- Adds optional fullstack dependencies and feature flags for web/server builds
- Implements server-side query storage and serialization using dioxus-fullstack-protocol
- Introduces
use_server_queryhook for fullstack query execution
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/query.rs | Adds fullstack query functionality with server-side caching and new use_server_query hook |
| Cargo.toml | Adds optional fullstack dependencies and feature flags |
| rust-toolchain.toml | Pins Rust version to 1.88.0 |
| .vscode/settings.json | Configures VS Code to use both server and web features |
Comments suppressed due to low confidence (4)
src/query.rs:260
- [nitpick] The method name
insert_or_get_server_queryis ambiguous about what makes it different from the existinginsert_or_get_querymethod. Consider renaming toinsert_or_get_fullstack_queryorinsert_or_get_serializable_queryto better reflect its purpose.
fn insert_or_get_server_query(&mut self, query: Query<Q>) -> QueryData<Q>
src/query.rs:504
- [nitpick] The method name
run_server_queriesis inconsistent with the existingrun_queriesmethod and doesn't clearly indicate the difference. Consider renaming torun_fullstack_queriesorrun_serializable_queriesto match the naming pattern.
async fn run_server_queries(queries: &[(&Query<Q>, &QueryData<Q>)])
src/query.rs:895
- [nitpick] The function name
use_server_querysuggests it only works on the server, but it's actually for fullstack usage (both web and server). Consider renaming touse_fullstack_queryto better reflect its purpose.
pub fn use_server_query<Q: QueryCapability>(query: Query<Q>) -> UseQuery<Q>
rust-toolchain.toml:2
- Rust version 1.88.0 does not exist. The latest stable Rust version as of my knowledge cutoff was 1.83. Please verify and use a valid Rust version.
channel = "1.88.0"
|
|
||
| // Cache the data if on the server | ||
| #[cfg(feature = "server")] | ||
| if let Some(storage_entry) = query_data.storage_entry.borrow_mut().take() { |
Copilot
AI
Jul 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The take() operation removes the storage entry permanently, which means subsequent query runs won't be able to cache data. Consider using as_ref() or cloning the entry instead of taking ownership.
| if let Some(storage_entry) = query_data.storage_entry.borrow_mut().take() { | |
| if let Some(storage_entry) = query_data.storage_entry.borrow().as_ref() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, its fine to take it as this will only run once, plus I need the owned version in order to call the insert thingy
|
@marc2332 behaviour did not change for ssr, it seems to not resolve at all. While I don't really need ssr, fullstack is just so convenient, |
|
id like to see server functions n hydration supported :( |
Based off #44
Closes #45