-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic example dosn't seem to work #53
Comments
@somehowchris you just need to add the various dependencies described in this error log to your Cargo.toml. Firstly, if you want to use However, this does bring up one item, which I had considered, but released the alpha in part to be able to solicit feedback on this issue. I think I'm going to add |
@somehowchris did adding those deps solve the problem? |
#54 should address this issue. The other items, you will have to add as deps on your own. If you still have any problems, or need guidance on how to add those crates as dependencies to your project, just let me know. |
I am using // main.rs
use futures::stream::StreamExt;
use serde::{Deserialize, Serialize};
use wither::bson::{doc, oid::ObjectId};
use wither::mongodb::Client;
use wither::prelude::*;
#[derive(Debug, Model, Serialize, Deserialize)]
#[model(index(keys = r#"doc!{"email": 1}"#, options = r#"doc!{"unique": true}"#))]
struct User {
/// The ID of the model.
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
pub id: Option<ObjectId>,
/// The user's email address.
pub email: String,
}
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let db = Client::with_uri_str("mongodb://localhost:27017/").await.unwrap().database("mydb");
let mut cursor = User::find(db.clone(), None, None).await.unwrap();
while let Some(user) = cursor.next().await {
println!("{:?}", user);
}
let mut app = tide::with_state(db);
app.at("/").get(|_| async { Ok("Hello, world!!!!") });
app.listen("127.0.0.1:8080").await?;
Ok(())
} // cargo.toml
[package]
name = "graphql-tide-server"
version = "0.1.0"
authors = ["Ruman <rumanbsl@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tide = "0.11.0"
async-std = { version = "1.6.2", features = ["attributes"] }
juniper = "0.14.2"
serde= { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.56"
wither = "0.9.0-alpha.1"
wither_derive = "0.9.0-alpha.1"
validator = "0.10"
validator_derive = "0.10"
futures = "0.3.5" giving Error Running `target/debug/graphql-tide-server`
thread 'main' panicked at 'there is no timer running, must be called from the context of
Tokio runtime', /Users/<USER>/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/time/driver/handle.rs:24:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Finished running. Exit status: 101] |
Mongo is giving some error with async-std (switching async-std to 1.5 didn't help either) failed to select a version for `async-std`.
... required by package `mongodb v1.0.0`
... which is depended on by `wither v0.9.0-alpha.1`
... which is depended on by `graphql-tide-server v0.1.0 (/Users/<USER>/Documents/dev/RUST_WORKSPACE/graphql-tide-server)`
versions that meet the requirements `~1.5.0` are: 1.5.0
all possible versions conflict with previously selected packages.
previously selected package `async-std v1.6.2`
... which is depended on by `async-h1 v2.0.2`
... which is depended on by `tide v0.11.0`
... which is depended on by `graphql-tide-server v0.1.0 (/Users/<USER>/Documents/dev/RUST_WORKSPACE/graphql-tide-server)`
failed to select a version for `async-std` which could resolve this conflict I have resolved it by enabling tokio runtime in async_std for now, incase someone stumbled with the same problem.
|
So, to be sure, Wither itself does not directly depend on tokio or async-std. So the dependency which needs to be match is whatever version Either way, you absolutely should update your dependency on wither as I mentioned above: wither = { version = "0.9.0-alpha.1", default-features = false, features = ["async-std-runtime"] } I would recommend that you try that, and if you still run into issues, I'm still happy to help, I would just ask that you paste your Cargo.toml dependencies here so that I can try to pinpoint the issue. |
The problem is with different version of |
@rumanbsl what we should probably do is request that the mongo team loosen their async-std requirement to “1” instead of a specific minor version like “1.5”. |
@thedodd It definitely make sense to pin only major version from mongo side, or for that matter any library |
Hey man,
I'm somewhat new to rust and really appreciate your work.
I wanted to set up a new project and just copied your example code from the README but It doesn't seem to work for me. Am I doing something wrong?
The text was updated successfully, but these errors were encountered: