From 34b65315761a15d83579259f4643ce48d48d3a27 Mon Sep 17 00:00:00 2001 From: Sunli Date: Sun, 11 Oct 2020 21:36:28 +0800 Subject: [PATCH] 2.0.0-alpha.26 --- Cargo.toml | 8 ++++---- benchmark/Cargo.toml | 2 +- benchmark/chat/Cargo.toml | 2 +- benchmark/simple/Cargo.toml | 2 +- derive/Cargo.toml | 4 ++-- integrations/actix-web/Cargo.toml | 4 ++-- integrations/rocket/Cargo.toml | 4 ++-- integrations/tide/Cargo.toml | 4 ++-- integrations/warp/Cargo.toml | 4 ++-- parser/Cargo.toml | 4 ++-- value/Cargo.toml | 2 +- value/src/de.rs | 26 ++++++++++++++++++++++++-- 12 files changed, 44 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4eefa457..12dfbca9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["sunli ", "Koxiaet"] edition = "2018" description = "A GraphQL server library implemented in Rust" @@ -24,9 +24,9 @@ string_number = ["num-traits"] nightly = [] [dependencies] -async-graphql-derive = { path = "derive", version = "2.0.0-alpha.25" } -async-graphql-value = { path = "value", version = "2.0.0-alpha.25" } -async-graphql-parser = { path = "parser", version = "2.0.0-alpha.25" } +async-graphql-derive = { path = "derive", version = "2.0.0-alpha.26" } +async-graphql-value = { path = "value", version = "2.0.0-alpha.26" } +async-graphql-parser = { path = "parser", version = "2.0.0-alpha.26" } async-stream = "0.3" async-trait = "0.1.30" diff --git a/benchmark/Cargo.toml b/benchmark/Cargo.toml index a841e327..37a287fa 100644 --- a/benchmark/Cargo.toml +++ b/benchmark/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "graphql-benchmark" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["sunli ", "Koxiaet"] edition = "2018" diff --git a/benchmark/chat/Cargo.toml b/benchmark/chat/Cargo.toml index 7801493b..192cd984 100644 --- a/benchmark/chat/Cargo.toml +++ b/benchmark/chat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chat" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["Ivan Plesskih "] edition = "2018" diff --git a/benchmark/simple/Cargo.toml b/benchmark/simple/Cargo.toml index e39a8991..625b23be 100644 --- a/benchmark/simple/Cargo.toml +++ b/benchmark/simple/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["Ivan Plesskih "] edition = "2018" diff --git a/derive/Cargo.toml b/derive/Cargo.toml index 14c15789..55d11cc2 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-derive" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["sunli ", "Koxiaet"] 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.25" } +async-graphql-parser = { path = "../parser", version = "2.0.0-alpha.26" } proc-macro2 = "1.0.6" syn = { version = "1.0.20", features = ["full", "extra-traits"] } quote = "1.0.3" diff --git a/integrations/actix-web/Cargo.toml b/integrations/actix-web/Cargo.toml index addc8de3..eff694f8 100644 --- a/integrations/actix-web/Cargo.toml +++ b/integrations/actix-web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-actix-web" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["sunli ", "Koxiaet"] 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.25" } +async-graphql = { path = "../..", version = "2.0.0-alpha.26" } actix-web = { version = "3.0.2", default-features = false } actix-web-actors = "3.0.0" actix-http = "2.0.0" diff --git a/integrations/rocket/Cargo.toml b/integrations/rocket/Cargo.toml index b2ccce21..5fef0b4a 100644 --- a/integrations/rocket/Cargo.toml +++ b/integrations/rocket/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-rocket" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["Daniel Wiesenberg "] 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.25" } +async-graphql = { path = "../..", version = "2.0.0-alpha.26" } 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" diff --git a/integrations/tide/Cargo.toml b/integrations/tide/Cargo.toml index 417e4b14..54f990cd 100644 --- a/integrations/tide/Cargo.toml +++ b/integrations/tide/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-tide" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["vkill "] 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.25" } +async-graphql = { path = "../..", version = "2.0.0-alpha.26" } tide = { version = "0.13.0", default-features = false, features = ["h1-server"] } async-trait = "0.1.36" serde_json = "1.0.56" diff --git a/integrations/warp/Cargo.toml b/integrations/warp/Cargo.toml index abe64fb9..505e57ad 100644 --- a/integrations/warp/Cargo.toml +++ b/integrations/warp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-warp" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["sunli ", "Koxiaet"] 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.25" } +async-graphql = { path = "../..", version = "2.0.0-alpha.26" } warp = { version = "0.2", default-features = false, features = ["websocket"] } futures = "0.3.0" bytes = "0.5.4" diff --git a/parser/Cargo.toml b/parser/Cargo.toml index 69332db8..3734586a 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-parser" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["sunli ", "Koxiaet"] edition = "2018" description = "GraphQL query parser for async-graphql" @@ -13,7 +13,7 @@ keywords = ["futures", "async", "graphql"] categories = ["network-programming", "asynchronous"] [dependencies] -async-graphql-value = { path = "../value", version = "2.0.0-alpha.25" } +async-graphql-value = { path = "../value", version = "2.0.0-alpha.26" } pest = "2.1.3" pest_derive = "2.1.0" serde_json = "1.0.57" diff --git a/value/Cargo.toml b/value/Cargo.toml index 6aeb3ce0..353d2086 100644 --- a/value/Cargo.toml +++ b/value/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-value" -version = "2.0.0-alpha.25" +version = "2.0.0-alpha.26" authors = ["sunli ", "Koxiaet"] edition = "2018" description = "GraphQL value for async-graphql" diff --git a/value/src/de.rs b/value/src/de.rs index 94c4b5bc..34bf18a1 100644 --- a/value/src/de.rs +++ b/value/src/de.rs @@ -425,9 +425,23 @@ impl<'de> serde::Deserializer<'de> for MapKeyDeserializer { NameDeserializer::new(self.key).deserialize_any(visitor) } + fn deserialize_enum( + self, + name: &'static str, + variants: &'static [&'static str], + visitor: V, + ) -> Result + where + V: Visitor<'de>, + { + self.key + .into_deserializer() + .deserialize_enum(name, variants, visitor) + } + forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string - bytes byte_buf unit unit_struct seq tuple option newtype_struct enum + bytes byte_buf unit unit_struct seq tuple option newtype_struct tuple_struct map struct identifier ignored_any } } @@ -469,6 +483,7 @@ mod tests { use super::*; use crate::Number; use serde::Deserialize; + use std::collections::HashMap; #[test] fn test_deserializer() { @@ -502,7 +517,7 @@ mod tests { let n: NewType = from_value(ConstValue::Number(100i32.into())).unwrap(); assert_eq!(n.0, 100); - #[derive(Deserialize, Debug, Eq, PartialEq)] + #[derive(Deserialize, Debug, Eq, PartialEq, Hash, Copy, Clone)] enum Enum { A, B, @@ -513,6 +528,13 @@ mod tests { let n: Enum = from_value(ConstValue::Enum(Name::new("B"))).unwrap(); assert_eq!(n, Enum::B); + let mut obj = BTreeMap::::new(); + obj.insert(Name::new("A"), ConstValue::Number(10.into())); + obj.insert(Name::new("B"), ConstValue::Number(20.into())); + let n: HashMap = from_value(ConstValue::Object(obj)).unwrap(); + assert_eq!(10, n[&Enum::A]); + assert_eq!(20, n[&Enum::B]); + #[derive(Deserialize, Debug, Eq, PartialEq)] struct Struct { a: i32,