2.0.0-alpha.5
This commit is contained in:
parent
fd35272f62
commit
5bb705bdf3
|
@ -21,7 +21,7 @@ jobs:
|
|||
- name: Run cargo-tarpaulin
|
||||
uses: actions-rs/tarpaulin@v0.1
|
||||
with:
|
||||
version: '0.11.0'
|
||||
version: '0.14.3'
|
||||
args: --out Xml --all --all-features
|
||||
- name: Upload to codecov.io
|
||||
uses: codecov/codecov-action@v1.0.2
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "async-graphql"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["sunli <scott_s829@163.com>"]
|
||||
edition = "2018"
|
||||
description = "A GraphQL server library implemented in Rust"
|
||||
|
@ -17,8 +17,8 @@ readme = "README.md"
|
|||
default = ["bson", "url", "chrono-tz"]
|
||||
|
||||
[dependencies]
|
||||
async-graphql-derive = { path = "derive", version = "2.0.0-alpha.4" }
|
||||
async-graphql-parser = { path = "parser", version = "2.0.0-alpha.4" }
|
||||
async-graphql-derive = { path = "derive", version = "2.0.0-alpha.5" }
|
||||
async-graphql-parser = { path = "parser", version = "2.0.0-alpha.5" }
|
||||
|
||||
async-stream = "0.3"
|
||||
async-trait = "0.1.30"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "graphql-benchmark"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["sunli <scott_s829@163.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "chat"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["Ivan Plesskih <terma95@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "simple"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["Ivan Plesskih <terma95@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "async-graphql-derive"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["sunli <scott_s829@163.com>"]
|
||||
edition = "2018"
|
||||
description = "Macros for async-graphql"
|
||||
|
@ -16,7 +16,7 @@ categories = ["network-programming", "asynchronous"]
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
async-graphql-parser = { path = "../parser", version = "2.0.0-alpha.4" }
|
||||
async-graphql-parser = { path = "../parser", version = "2.0.0-alpha.5" }
|
||||
proc-macro2 = "1.0.6"
|
||||
syn = { version = "1.0.20", features = ["full", "extra-traits"] }
|
||||
quote = "1.0.3"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "async-graphql-actix-web"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["sunli <scott_s829@163.com>"]
|
||||
edition = "2018"
|
||||
description = "async-graphql for actix-web"
|
||||
|
@ -13,7 +13,7 @@ keywords = ["futures", "async", "graphql"]
|
|||
categories = ["network-programming", "asynchronous"]
|
||||
|
||||
[dependencies]
|
||||
async-graphql = { path = "../..", version = "2.0.0-alpha.4" }
|
||||
async-graphql = { path = "../..", version = "2.0.0-alpha.5" }
|
||||
actix-web = "3.0.0"
|
||||
actix-web-actors = "3.0.0"
|
||||
actix = "0.10.0"
|
||||
|
|
|
@ -66,10 +66,8 @@ where
|
|||
fn started(&mut self, ctx: &mut Self::Context) {
|
||||
self.hb(ctx);
|
||||
if let Some(initializer) = self.initializer.take() {
|
||||
let (sink, stream) = async_graphql::http::websocket::create_with_initializer(
|
||||
&self.schema,
|
||||
initializer,
|
||||
);
|
||||
let (sink, stream) =
|
||||
async_graphql::http::websocket::create_with_initializer(&self.schema, initializer);
|
||||
ctx.add_stream(stream);
|
||||
self.sink = Some(sink);
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "async-graphql-rocket"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["Daniel Wiesenberg <daniel@simplificAR.io>"]
|
||||
edition = "2018"
|
||||
description = "async-graphql for Rocket.rs"
|
||||
|
@ -14,7 +14,7 @@ keywords = ["futures", "async", "graphql", "rocket"]
|
|||
categories = ["network-programming", "asynchronous"]
|
||||
|
||||
[dependencies]
|
||||
async-graphql = { path = "../..", version = "2.0.0-alpha.4" }
|
||||
async-graphql = { path = "../..", version = "2.0.0-alpha.5" }
|
||||
rocket = { git = "https://github.com/SergioBenitez/Rocket/", rev = "dc2c6ec", default-features = false } #TODO: Change to Cargo crate, when Rocket 0.5.0 is released
|
||||
log = "0.4.11"
|
||||
yansi = "0.5.0"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "async-graphql-tide"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["vkill <vkill.net@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "async-graphql for tide"
|
||||
|
@ -13,7 +13,7 @@ keywords = ["futures", "async", "graphql"]
|
|||
categories = ["network-programming", "asynchronous"]
|
||||
|
||||
[dependencies]
|
||||
async-graphql = { path = "../..", version = "2.0.0-alpha.4" }
|
||||
async-graphql = { path = "../..", version = "2.0.0-alpha.5" }
|
||||
tide = "0.13.0"
|
||||
async-trait = "0.1.36"
|
||||
serde_json = "1.0.56"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "async-graphql-warp"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["sunli <scott_s829@163.com>"]
|
||||
edition = "2018"
|
||||
description = "async-graphql for warp"
|
||||
|
@ -13,7 +13,7 @@ keywords = ["futures", "async", "graphql"]
|
|||
categories = ["network-programming", "asynchronous"]
|
||||
|
||||
[dependencies]
|
||||
async-graphql = { path = "../..", version = "2.0.0-alpha.4" }
|
||||
async-graphql = { path = "../..", version = "2.0.0-alpha.5" }
|
||||
warp = "0.2.2"
|
||||
futures = "0.3.0"
|
||||
bytes = "0.5.4"
|
||||
|
|
|
@ -199,11 +199,10 @@ where
|
|||
|ws: warp::ws::Ws, schema: Schema<Query, Mutation, Subscription>, initializer: F| {
|
||||
ws.on_upgrade(move |websocket| {
|
||||
let (mut tx, rx) = websocket.split();
|
||||
let (mut stx, srx) =
|
||||
async_graphql::http::websocket::create_with_initializer(
|
||||
&schema,
|
||||
initializer,
|
||||
);
|
||||
let (mut stx, srx) = async_graphql::http::websocket::create_with_initializer(
|
||||
&schema,
|
||||
initializer,
|
||||
);
|
||||
|
||||
let mut rx = rx.fuse();
|
||||
let srx = srx.fuse();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "async-graphql-parser"
|
||||
version = "2.0.0-alpha.4"
|
||||
version = "2.0.0-alpha.5"
|
||||
authors = ["sunli <scott_s829@163.com>"]
|
||||
edition = "2018"
|
||||
description = "GraphQL query parser for async-graphql"
|
||||
|
|
|
@ -3,11 +3,11 @@ use bytes::Bytes;
|
|||
use futures::io::AsyncRead;
|
||||
use futures::stream::Stream;
|
||||
use multer::{Constraints, Multipart, SizeLimit};
|
||||
use pin_project_lite::pin_project;
|
||||
use std::collections::HashMap;
|
||||
use std::io::{self, Seek, SeekFrom, Write};
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use pin_project_lite::pin_project;
|
||||
|
||||
/// Options for `receive_multipart`.
|
||||
#[derive(Default, Clone)]
|
||||
|
@ -143,7 +143,7 @@ impl<T: AsyncRead> Stream for ReaderStream<T> {
|
|||
match futures::ready!(this.reader.poll_read(cx, this.buf)?) {
|
||||
0 => None,
|
||||
size => Some(Ok(Bytes::copy_from_slice(&this.buf[..size]))),
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,19 +112,19 @@ mod validation;
|
|||
|
||||
pub mod extensions;
|
||||
pub mod guard;
|
||||
pub mod validators;
|
||||
pub mod types;
|
||||
pub mod validators;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod resolver_utils;
|
||||
#[doc(hidden)]
|
||||
pub use async_graphql_parser as parser;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use async_trait;
|
||||
#[doc(hidden)]
|
||||
pub use async_stream;
|
||||
#[doc(hidden)]
|
||||
pub use async_trait;
|
||||
#[doc(hidden)]
|
||||
pub use futures;
|
||||
#[doc(hidden)]
|
||||
pub use indexmap;
|
||||
|
@ -148,8 +148,8 @@ pub use request::Request;
|
|||
pub use response::Response;
|
||||
pub use schema::{Schema, SchemaBuilder, SchemaEnv};
|
||||
pub use serde_json::Number;
|
||||
pub use validation::ValidationMode;
|
||||
pub use types::*;
|
||||
pub use validation::ValidationMode;
|
||||
|
||||
/// Result type
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
|
|
@ -24,16 +24,18 @@ pub fn parse_enum<T: EnumType>(value: Value) -> InputValueResult<T> {
|
|||
Value::String(s) => s.as_str(),
|
||||
_ => return Err(InputValueError::ExpectedType(value)),
|
||||
};
|
||||
|
||||
|
||||
T::items()
|
||||
.iter()
|
||||
.find(|item| item.name == value)
|
||||
.map(|item| item.value)
|
||||
.ok_or_else(|| InputValueError::Custom(format!(
|
||||
r#"Enumeration type "{}" does not contain the value "{}""#,
|
||||
T::type_name(),
|
||||
value,
|
||||
)))
|
||||
.ok_or_else(|| {
|
||||
InputValueError::Custom(format!(
|
||||
r#"Enumeration type "{}" does not contain the value "{}""#,
|
||||
T::type_name(),
|
||||
value,
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
/// Convert the enum value into a GraphQL value.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Utilities for implementing `OutputValueType::resolve`.
|
||||
|
||||
mod object;
|
||||
mod r#enum;
|
||||
mod object;
|
||||
|
||||
pub use object::*;
|
||||
pub use r#enum::*;
|
||||
|
|
|
@ -47,10 +47,7 @@ impl Response {
|
|||
/// Set the extensions result of the response.
|
||||
#[must_use]
|
||||
pub fn extensions(self, extensions: Option<serde_json::Value>) -> Self {
|
||||
Self {
|
||||
extensions,
|
||||
..self
|
||||
}
|
||||
Self { extensions, ..self }
|
||||
}
|
||||
|
||||
/// Set the cache control of the response.
|
||||
|
|
|
@ -405,9 +405,7 @@ where
|
|||
|
||||
let data = match &env.document.operation.node.ty {
|
||||
OperationType::Query => resolve_object(&ctx, &self.query).await,
|
||||
OperationType::Mutation => {
|
||||
resolve_object_serial(&ctx, &self.mutation).await
|
||||
}
|
||||
OperationType::Mutation => resolve_object_serial(&ctx, &self.mutation).await,
|
||||
OperationType::Subscription => {
|
||||
return Error::Query {
|
||||
pos: Pos::default(),
|
||||
|
@ -421,8 +419,7 @@ where
|
|||
env.extensions.lock().execution_end();
|
||||
let extensions = env.extensions.lock().result();
|
||||
|
||||
Response::from_result(data)
|
||||
.extensions(extensions)
|
||||
Response::from_result(data).extensions(extensions)
|
||||
}
|
||||
|
||||
/// Execute an GraphQL query.
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
use crate::{
|
||||
registry, Context, Error, Pos, QueryError, Result, SubscriptionType, Type,
|
||||
};
|
||||
use crate::{registry, Context, Error, Pos, QueryError, Result, SubscriptionType, Type};
|
||||
use futures::{stream, Stream};
|
||||
use std::borrow::Cow;
|
||||
use std::pin::Pin;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
//! Implementations of `Type`, `ScalarType`, etc on external types.
|
||||
|
||||
mod string;
|
||||
mod bool;
|
||||
mod datetime;
|
||||
mod floats;
|
||||
mod integers;
|
||||
mod list;
|
||||
mod optional;
|
||||
mod bool;
|
||||
mod integers;
|
||||
mod floats;
|
||||
mod string;
|
||||
mod url;
|
||||
mod uuid;
|
||||
mod datetime;
|
||||
|
||||
#[cfg(feature = "bson")]
|
||||
mod bson;
|
||||
|
|
|
@ -3,10 +3,9 @@ use crate::registry::{MetaType, Registry};
|
|||
use crate::resolver_utils::{resolve_object, ObjectType};
|
||||
use crate::{
|
||||
CacheControl, Context, ContextSelectionSet, Error, GQLSimpleObject, GQLSubscription,
|
||||
OutputValueType, Positioned, QueryError, Result,
|
||||
SubscriptionType, Type,
|
||||
OutputValueType, Positioned, QueryError, Result, SubscriptionType, Type,
|
||||
};
|
||||
use futures::{stream, Stream, StreamExt, future::Either};
|
||||
use futures::{future::Either, stream, Stream, StreamExt};
|
||||
use indexmap::IndexMap;
|
||||
use std::borrow::Cow;
|
||||
use std::pin::Pin;
|
||||
|
@ -112,20 +111,13 @@ where
|
|||
) -> Pin<Box<dyn Stream<Item = Result<serde_json::Value>> + Send + 'a>> {
|
||||
let left_stream = self.0.create_field_stream(ctx);
|
||||
let mut right_stream = Some(self.1.create_field_stream(ctx));
|
||||
Box::pin(
|
||||
left_stream
|
||||
.flat_map(move |res| {
|
||||
match res {
|
||||
Err(Error::Query {
|
||||
err: QueryError::FieldNotFound { .. },
|
||||
..
|
||||
}) if right_stream.is_some() => {
|
||||
Either::Right(right_stream.take().unwrap())
|
||||
}
|
||||
other => Either::Left(stream::once(async { other })),
|
||||
}
|
||||
})
|
||||
)
|
||||
Box::pin(left_stream.flat_map(move |res| match res {
|
||||
Err(Error::Query {
|
||||
err: QueryError::FieldNotFound { .. },
|
||||
..
|
||||
}) if right_stream.is_some() => Either::Right(right_stream.take().unwrap()),
|
||||
other => Either::Left(stream::once(async { other })),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,24 +3,24 @@
|
|||
pub mod connection;
|
||||
|
||||
mod any;
|
||||
mod json;
|
||||
mod empty_mutation;
|
||||
mod empty_subscription;
|
||||
mod id;
|
||||
mod json;
|
||||
mod maybe_undefined;
|
||||
mod merged_object;
|
||||
mod query_root;
|
||||
mod upload;
|
||||
mod id;
|
||||
|
||||
mod external;
|
||||
|
||||
pub use any::Any;
|
||||
pub use json::{Json, OutputJson};
|
||||
pub use empty_mutation::EmptyMutation;
|
||||
pub use empty_subscription::EmptySubscription;
|
||||
pub use id::ID;
|
||||
pub use json::{Json, OutputJson};
|
||||
pub use maybe_undefined::MaybeUndefined;
|
||||
pub use merged_object::{MergedObject, MergedObjectSubscriptionTail, MergedObjectTail};
|
||||
pub use upload::Upload;
|
||||
pub use id::ID;
|
||||
|
||||
pub(crate) use query_root::QueryRoot;
|
||||
|
|
|
@ -2,8 +2,8 @@ use crate::model::{__Schema, __Type};
|
|||
use crate::parser::types::Field;
|
||||
use crate::resolver_utils::{resolve_object, ObjectType};
|
||||
use crate::{
|
||||
registry, Any, Context, ContextSelectionSet, Error, GQLSimpleObject, OutputValueType, Positioned,
|
||||
QueryError, Result, Type,
|
||||
registry, Any, Context, ContextSelectionSet, Error, GQLSimpleObject, OutputValueType,
|
||||
Positioned, QueryError, Result, Type,
|
||||
};
|
||||
|
||||
use indexmap::map::IndexMap;
|
||||
|
|
|
@ -126,7 +126,10 @@ pub async fn test_field_features() {
|
|||
|
||||
let mut stream = schema.execute_stream("subscription { values }").boxed();
|
||||
assert_eq!(
|
||||
stream.next().await.map(|resp| resp.into_result().unwrap().data),
|
||||
stream
|
||||
.next()
|
||||
.await
|
||||
.map(|resp| resp.into_result().unwrap().data),
|
||||
Some(serde_json::json!({
|
||||
"values": 10
|
||||
}))
|
||||
|
|
Loading…
Reference in New Issue