web: upgrade to seed-0.10.0

This commit is contained in:
2023-12-05 20:46:59 -08:00
parent f2347345b4
commit c31f9d581f
7 changed files with 98 additions and 74 deletions

View File

@@ -1,8 +1,5 @@
use gloo_net::{http::Request, Error};
use graphql_client::GraphQLQuery;
use seed::{
fetch,
fetch::{Header, Method, Request},
};
use serde::{de::DeserializeOwned, Serialize};
// The paths are relative to the directory where your `Cargo.toml` is located.
@@ -23,21 +20,18 @@ pub struct FrontPageQuery;
)]
pub struct ShowThreadQuery;
pub async fn send_graphql<Body, Resp>(body: Body) -> fetch::Result<graphql_client::Response<Resp>>
pub async fn send_graphql<Body, Resp>(body: Body) -> Result<graphql_client::Response<Resp>, Error>
where
Body: Serialize,
Resp: DeserializeOwned + 'static,
{
use web_sys::RequestMode;
Request::new("/graphql/")
.method(Method::Post)
.header(Header::content_type("application/json"))
Request::post("/graphql/")
.mode(RequestMode::Cors)
.json(&body)?
.fetch()
.send()
.await?
.check_status()?
.json()
.await
}