-
Notifications
You must be signed in to change notification settings - Fork 434
Closed
Description
Hi,
I'm using Actix and I'm trying to set a context.
I've done the following
#[derive(Clone)]
pub struct Context {
pub client: reqwest::Client,
}
impl juniper::Context for Context {}
impl Context {
pub fn new(client: reqwest::Client) -> Self {
Self { client }
}
}
async fn graphql(
st: web::Data<Arc<Schema>>,
data: web::Json<GraphQLRequest>,
client: web::Data<reqwest::Client>,
) -> Result<HttpResponse, Error> {
let client = client.into_inner().as_ref().clone();
let ctx = Context::new(client);
let user = web::block(move || {
let res = data.execute(&st, &ctx);
Ok::<_, serde_json::error::Error>(serde_json::to_string(&res)?)
})
.await?;
Ok(HttpResponse::Ok()
.content_type("application/json")
.body(user))
}
I've done that by following what they did https://github.com/clifinger/canduma/blob/master/src/graphql/handler.rs and https://github.com/LantosTG/rust_site/blob/master/src/main.rs
But sadly I'm getting the following error:
error[E0308]: mismatched types
--> src/main.rs:43:37
|
43 | let res = data.execute(&st, &ctx);
| ^^^^ expected `()`, found struct `Context`
|
= note: expected reference `&()`
found reference `&Context`
I have no idea what I did wrong 😳
Metadata
Metadata
Assignees
Labels
No labels