Originally posted by **seun-ja** June 21, 2023
I'm currently working on a web app project. It's built using Actix and for the database, Postgres. I'm currently trying to implement Graphql, read the documentation even followed an example using Actix in the repo yet I get this response
`Requested application data is not configured correctly. View/enable debug logs for more details.`
let graphql_schema = Data::new(schema());
```
HttpServer::new(move || {
App::new()
.wrap(TracingLogger::default())
.wrap(
Cors::default()
.allow_any_origin()
.allowed_methods(vec!["POST", "GET", "PUT", "DELETE"])
.allowed_headers(vec![
header::AUTHORIZATION,
header::ACCEPT,
header::DATE,
header::CONTENT_LENGTH,
])
.allowed_header(header::CONTENT_TYPE)
.supports_credentials()
.max_age(3600),
)
.route("/", web::get().to(home))
.route("/health_check", web::get().to(health_check))
.route("/graphql", web::post().to(graphql))
.route("/graphiql", web::get().to(graphiql)),
)
.app_data(db_pool.clone())
.app_data(graphql_schema.clone())
.app_data(schema_context.clone())
})
.listen(listener)?
.run()
```
```
pub async fn graphql(
st: web::Data,
data: web::Json,
ctx: web::Data,
) -> Result {
let res = data.execute(&st, &ctx).await;
let res_data = serde_json::to_string(&res).unwrap();
Ok(HttpResponse::Ok()
.content_type("application/json")
.body(res_data))
}
```
```
#[derive(Clone, Debug)]
pub struct Query;
#[graphql_object(context = Context)]
impl Query {
fn api_version() -> &'static str {
"1.0"
}
fn streamlink(
&self,
ctx: &Context,
id: String,
) -> FieldResult {
let link = get_stream_link(id, &ctx.pool)
.map_err(|_e| {
return FieldError::::new(
"Product Not Found",
graphql_value!({ "not_found": "product not found" }),
);
})
.unwrap();
Ok(Stream {
link
})
}
}
pub type Schema = RootNode<'static, Query, EmptyMutation, EmptySubscription>;
pub fn schema() -> Schema {
Schema::new(Query, EmptyMutation::::new(), EmptySubscription::::new())
}
```
what could I be missing :(
Discussed in https://github.com/graphql-rust/juniper/discussions/1170