leptos-query icon indicating copy to clipboard operation
leptos-query copied to clipboard

QueryValue is tied to Leptos Serializable

Open Innominus opened this issue 7 months ago • 0 comments

I've run into a blocker trying to implement serde-lite or rkyv as my output for server functions in leptos. Note, this is purely CSR with no SSR. I have the CSR feature flag on, and no SSR flag.

Trying to implement serde-lite yields errors related to QueryValue not being implemented on my return types. It wants it to implement server_fn::serde::{Serialize, Deserialize} etc. This constraint can only be changed if you add the feature flag to Leptos for serde-lite. But this does not control the input or output from server functions. It only controls the initial streaming on first request in SSR mode. It seems the only way to change the underlying serializer of QueryValue is to set this feature flag, which doesn't allow for the other serializing types such as bson, toml, rkyv, etc etc.

Asides from that I'm having trouble just implementing serde-lite. So with the feature flag on, I get this as my error: image image The Result<T,E> type does not have an implementation in serde-lite, and Leptos server functions don't expect it to. I've been told that Leptos server functions serialize the Result type that's returned from server functions as a http request, and the actual T value and E error are required to be serialized to the desired format. But I think Leptos Query relies on the entire return type being Serializable, but serde-lite does not have an implementation for the Result type.

If we ignore all of this, in Leptos Query's current state, how would I implement rkyv input and output on my types and use it with Leptos Query?

Thanks! Also, amazing library. This has been my only hiccup so far because I don't want monomorphization so I can keep my binary as small as possible. Appreciate all the work that's gone into this.

Innominus avatar Jul 17 '24 03:07 Innominus