v0.2.0
This release comes with a bunch of breaking changes to prepare existing rspc projects for the upcoming 0.3.0 release.
This release is only possible due to the support of my sponsors!
A huge thanks to @scottwey, @michael-dm and @TmLev for supporting me. If you are using rspc and you or your company is able to support the project it would be greatly appreciated as it ensures the product is sustainable long-term!
tldr of changes
- Fix websocket when using the Axum integration which I broke in the
0.1.4
release earlier today - Drop
httpz
from rspc core. I have deprecated this crate as I don't think it's serving it's purpose very well. All integrations are moving intorspc_*
crates. - Remove Specta reexports and Specta features from the rspc crate
- Restart subscriptions and in-progress requests when the websocket connection reconnects.
- Websocket support is now optional and requires the
ws
feature to be enabled on therspc_axum
crate. - Expose
AppHandle
to Tauri context function as the first argument - fixes #244
These changes should hopefully fix the most comments issues I hear when talking with people about rspc.
Upgrade Guide:
Bump dependency versions
# Backend
cargo add rspc@0.2.0
# Frontend
pnpm install @rspc/client@0.2.0
pnpm install @rspc/react@0.2.0
pnpm install @rspc/solid@0.2.0
pnpm install @rspc/tauri@0.2.0
Removal of rspc::Type
rspc::Type
is currently a reexport of specta::Type
and to make versioning easier we have removed it in this rspc release. To upgrade:
Make sure you have Specta installed in your project.
cargo add specta
Then replace all rspc::Type
imports with specta::Type
.
Removal of many features from rspc
crate
This release drops a lot of features from the rspc
crate. I have documented them by category below:
Specta-related flags
This includes uuid
, chrono
, time
, bigdecimal
, rust_decimal
, indexmap
, ipnetwork
, mac_address
, bit-vec
and bson
.
You should instead move the feature onto the specta
crate.
Eg.
- rspc = { version = "0.1.4", features = ["chrono"] }
+ rspc = "0.2.0"
+ specta = { version = "1", features = ["chrono"] }
Webservers
This includes httpz
, tauri
, axum
, lambda
, workers
. You should follow the guide for your integration under the next heading.
Break out integrations into dedicated crates
This is going to make versioning significantly easier which would mean more frequent bug fixes and depedency upgrades.
This included removing .endpoint
and the rspc::integrations
module in favor of splitting the logic over multiple crates.
Follow the guide below based on your chosen integration:
Axum
First, remove the old feature flag and add the new rspc_axum
crate.
- rspc = { version = "0.1.4", features = ["axum"] }
+ rspc = "0.2.0"
+ rspc_axum = { version = "0.1.1", features = ["ws"] } # Websocket support is now optional
Next, upgrade the code in your project:
let app = axum::Router::new()
.route("/", get(|| async { "Hello 'rspc'!" }))
.nest(
"/rspc",
- router
- .clone()
- .endpoint(|| { ... })
- .axum(),
+ rspc_axum::endpoint(router.clone(), | | { ... }),
)
.layer(cors);
Tauri
First, remove the old feature flag and add the new rspc_tauri
crate.
- rspc = { version = "0.1.4", features = ["tauri"] }
+ rspc = "0.2.0"
+ rspc_tauri = { version = "0.0.1" }
Next, upgrade the code in your project:
tauri::Builder::default()
- .plugin(rspc::integrations::tauri::plugin(router.arced(), || { ... }))
+ .plugin(rspc_tauri:plugin(router.arced(), |_| { ... }))
Lambda
This feature has been removed. It's recommend you use the Axum integration with cargo-lambda
like this example.
Workers
This feature has been removed. It currently has no direct replacement but will be brought back in the near future.
If you are actively using it, please contact me on the rspc/PCR Discord and we can get something sorted.
Tanstack Query v5
This release requires you upgrade to Tanstack Query v5. You can follow their upgrade guide here.
Solid Query
Solid Query has changed the way its arguments are parsed upstream so we decided to copy this. You will need to update all of your createQuery
, createMutation
, etc hooks to the new syntax.
For queries you will need to make the following changes:
rspc.createQuery(
- () => ["echo", "somevalue"],
- () => ({
- enabled: true,
- })
+ () => ({
+ queryKey: ["echo", "somevalue"],
+ enabled: true
+ })
);
For mutations, you will need to use the mutationKey
property to choice the mutation is the same style.
Usage with Prisma Client Rust
If your using Prisma Client Rust 0.6.x
you can use the rspc-0.2.0
branch:
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", rev = "8faf98013d0d2c7fab68fad387305a55979e777d" }
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", rev = "8faf98013d0d2c7fab68fad387305a55979e777d" }