actix / examples

Community showcase and examples of Actix Web ecosystem usage.
Apache License 2.0
3.7k stars 807 forks source link

Juniper example fails to compile #214

Closed 0x4d6165 closed 4 years ago

0x4d6165 commented 4 years ago

Howdy! These are the errors I get when I try to compile the juniper example in Rust 2018

error[E0277]: the trait bound `impl futures::future::Future: std::future::Future` is not satisfied
   --> src/main.rs:23:16
    |
23  |       let user = web::block(move || {
    |  ________________^
24  | |         let res = data.execute(&st, &());
25  | |         Ok::<_, serde_json::error::Error>(serde_json::to_string(&res)?)
26  | |     })
27  | |     .await?;
    | |__________^ the trait `std::future::Future` is not implemented for `impl futures::future::Future`

error[E0277]: the trait bound `fn(actix_web::data::Data<std::sync::Arc<juniper::schema::model::RootNode<'static, schema::QueryRoot, schema::MutationRoot>>>, actix_web::types::json::Json<juniper::http::GraphQLRequest>) -> impl std::future::Future {graphql}: actix_web::handler::Factory<_, _>` is not satisfied
  --> src/main.rs:46:69
   |
46 |             .service(web::resource("/graphql").route(web::post().to(graphql)))
   |                                                                     ^^^^^^^ the trait `actix_web::handler::Factory<_, _>` is not implemented for `fn(actix_web::data::Data<std::sync::Arc<juniper::schema::model::RootNode<'static, schema::QueryRoot, schema::MutationRoot>>>, actix_web::types::json::Json<juniper::http::GraphQLRequest>) -> impl std::future::Future {graphql}`

error[E0277]: the trait bound `fn() -> impl std::future::Future {graphiql}: actix_web::handler::Factory<_, _>` is not satisfied
  --> src/main.rs:47:69
   |
47 |             .service(web::resource("/graphiql").route(web::get().to(graphiql)))
   |                                                                     ^^^^^^^^ the trait `actix_web::handler::Factory<_, _>` is not implemented for `fn() -> impl std::future::Future {graphiql}`

error[E0277]: the trait bound `actix_server::server::Server: std::future::Future` is not satisfied
   --> src/main.rs:42:5
    |
42  | /     HttpServer::new(move || {
43  | |         App::new()
44  | |             .data(schema.clone())
45  | |             .wrap(middleware::Logger::default())
...   |
50  | |     .start()
51  | |     .await
    | |__________^ the trait `std::future::Future` is not implemented for `actix_server::server::Server`

error: aborting due to 4 previous errors
JohnTitor commented 4 years ago

The example works for me, could you double-check if your code and dependencies are the same as the example's (#215 is also)?

0x4d6165 commented 4 years ago

Oops! Didn't see that the examples depended on a RC version of actix. Also is there anyway to get rid of the extern crate lines since 2018 is out?

JohnTitor commented 4 years ago

Also is there any way to get rid of the extern crate lines since 2018 is out?

These examples use extern crate for #[macro_use] so you should import macros individually to remove them.

Closing since these examples work fine.