Fixed all tests.
This commit is contained in:
parent
ed2b73949a
commit
43bf61754a
|
@ -20,5 +20,5 @@ tide = { version = "0.13.0", default-features = false, features = ["h1-server"]
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# Surf lacks multipart support
|
# Surf lacks multipart support
|
||||||
reqwest = { version = "0.10.8", default-features = false, features = ["json"] }
|
reqwest = { version = "0.10.8", default-features = false, features = ["json"] }
|
||||||
tokio = { version = "0.3.0", default-features = false, features = ["macros"] }
|
async-std = { version = "1.6.5", features = ["attributes", "tokio02"] }
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
|
|
|
@ -9,11 +9,11 @@ use async_graphql::*;
|
||||||
|
|
||||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
||||||
|
|
||||||
#[tokio::test(max_threads = 1)]
|
#[async_std::test]
|
||||||
async fn quickstart() -> Result<()> {
|
async fn quickstart() -> Result<()> {
|
||||||
let listen_addr = test_utils::find_listen_addr();
|
let listen_addr = test_utils::find_listen_addr();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
async_std::task::spawn(async move {
|
||||||
struct QueryRoot;
|
struct QueryRoot;
|
||||||
#[Object]
|
#[Object]
|
||||||
impl QueryRoot {
|
impl QueryRoot {
|
||||||
|
@ -63,11 +63,11 @@ async fn quickstart() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(max_threads = 1)]
|
#[async_std::test]
|
||||||
async fn hello() -> Result<()> {
|
async fn hello() -> Result<()> {
|
||||||
let listen_addr = test_utils::find_listen_addr();
|
let listen_addr = test_utils::find_listen_addr();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
async_std::task::spawn(async move {
|
||||||
struct Hello(String);
|
struct Hello(String);
|
||||||
struct QueryRoot;
|
struct QueryRoot;
|
||||||
#[Object]
|
#[Object]
|
||||||
|
@ -136,11 +136,11 @@ async fn hello() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(max_threads = 1)]
|
#[async_std::test]
|
||||||
async fn upload() -> Result<()> {
|
async fn upload() -> Result<()> {
|
||||||
let listen_addr = test_utils::find_listen_addr();
|
let listen_addr = test_utils::find_listen_addr();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
async_std::task::spawn(async move {
|
||||||
struct QueryRoot;
|
struct QueryRoot;
|
||||||
#[Object]
|
#[Object]
|
||||||
impl QueryRoot {}
|
impl QueryRoot {}
|
||||||
|
|
|
@ -19,5 +19,5 @@ pub fn client() -> Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn wait_server_ready() {
|
pub async fn wait_server_ready() {
|
||||||
tokio::time::delay_for(Duration::from_millis(300)).await;
|
async_std::task::sleep(Duration::from_millis(300)).await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ version = "2.0.3"
|
||||||
authors = ["sunli <scott_s829@163.com>", "Koxiaet"]
|
authors = ["sunli <scott_s829@163.com>", "Koxiaet"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "async-graphql for warp"
|
description = "async-graphql for warp"
|
||||||
|
publish = true
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
documentation = "https://docs.rs/async-graphql/"
|
documentation = "https://docs.rs/async-graphql/"
|
||||||
homepage = "https://github.com/async-graphql/async-graphql"
|
homepage = "https://github.com/async-graphql/async-graphql"
|
||||||
|
@ -19,4 +20,4 @@ futures-util = { version = "0.3.6", default-features = false }
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "0.3.0", default-features = false, features = ["macros"] }
|
tokio = { version = "0.3.0", default-features = false, features = ["macros", "rt-multi-thread", "time", "stream"] }
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
//! Async-graphql integration with Warp
|
//! Async-graphql integration with Warp
|
||||||
|
|
||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity)]
|
||||||
#![allow(clippy::needless_doctest_main)]
|
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
mod batch_request;
|
mod batch_request;
|
||||||
|
|
|
@ -31,15 +31,14 @@ use crate::{graphql_batch_opts, BadRequest, BatchResponse};
|
||||||
///
|
///
|
||||||
/// type MySchema = Schema<QueryRoot, EmptyMutation, EmptySubscription>;
|
/// type MySchema = Schema<QueryRoot, EmptyMutation, EmptySubscription>;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||||
/// async fn main() {
|
|
||||||
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
|
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
|
||||||
/// let filter = async_graphql_warp::graphql(schema)
|
/// let filter = async_graphql_warp::graphql(schema)
|
||||||
/// .and_then(|(schema, request): (MySchema, async_graphql::Request)| async move {
|
/// .and_then(|(schema, request): (MySchema, async_graphql::Request)| async move {
|
||||||
/// Ok::<_, Infallible>(async_graphql_warp::Response::from(schema.execute(request).await))
|
/// Ok::<_, Infallible>(async_graphql_warp::Response::from(schema.execute(request).await))
|
||||||
/// });
|
/// });
|
||||||
/// warp::serve(filter).run(([0, 0, 0, 0], 8000)).await;
|
/// warp::serve(filter).run(([0, 0, 0, 0], 8000)).await;
|
||||||
/// }
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
pub fn graphql<Query, Mutation, Subscription>(
|
pub fn graphql<Query, Mutation, Subscription>(
|
||||||
schema: Schema<Query, Mutation, Subscription>,
|
schema: Schema<Query, Mutation, Subscription>,
|
||||||
|
|
|
@ -28,13 +28,12 @@ use warp::{Filter, Rejection, Reply};
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||||
/// async fn main() {
|
|
||||||
/// let schema = Schema::new(QueryRoot, EmptyMutation, SubscriptionRoot);
|
/// let schema = Schema::new(QueryRoot, EmptyMutation, SubscriptionRoot);
|
||||||
/// let filter = async_graphql_warp::graphql_subscription(schema)
|
/// let filter = async_graphql_warp::graphql_subscription(schema)
|
||||||
/// .or(warp::any().map(|| "Hello, World!"));
|
/// .or(warp::any().map(|| "Hello, World!"));
|
||||||
/// warp::serve(filter).run(([0, 0, 0, 0], 8000)).await;
|
/// warp::serve(filter).run(([0, 0, 0, 0], 8000)).await;
|
||||||
/// }
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
pub fn graphql_subscription<Query, Mutation, Subscription>(
|
pub fn graphql_subscription<Query, Mutation, Subscription>(
|
||||||
schema: Schema<Query, Mutation, Subscription>,
|
schema: Schema<Query, Mutation, Subscription>,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user