I'm switching from Nodejs with NestJs to Rust Rocket + juniper. Even if I start feeling confident in Rust i'm having difficulties with some simple thing.
I'm trying to create a mongdb pool to attach to my app but I'm having some issue. Here is my main function:
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[macro_use] extern crate rocket_contrib;
#[rocket_contrib::database("db")]
struct DatabaseConnection(rocket_contrib::databases::mongodb::db::Database);
// mod features;
#[rocket::main]
async fn main() {
rocket::build()
.attach(DatabaseConnection::fairing())
.mount(
"/",
rocket::routes![],
)
.launch()
.await
.expect("server to launch");
}
And here is my cargo.toml file:
[package]
name = "rocket_graphql"
version = "0.1.0"
edition = "2018"
[dependencies]
rocket = "0.5.0-rc.1"
juniper = { git = "https://github.com/graphql-rust/juniper" }
juniper_rocket = "0.2.0"
mongodb = "2.0.0-beta.2"
bson = "1.2.1"
tokio = { version = "1.8.0", features = ["full"] }
[dependencies.rocket_contrib]
version = "0.4.10"
default-features = false
features = ["mongodb_pool"]
[global.databases]
db = {url = "my-mongo-atlas-instance-url"}
I'm getting an error on this line #[rocket_contrib::database("db")]
it says: unresolved import 'rocket' no 'Outcome' in the root.
Can you please tell me what I'm doing wrong here?
Thank you very much