From 6657dbb68f82af0c750c75a27b494db80a8980a1 Mon Sep 17 00:00:00 2001 From: Sunli Date: Wed, 9 Sep 2020 15:17:44 +0800 Subject: [PATCH 1/3] Update code-coverage.yml --- .github/workflows/code-coverage.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 43b03881..985a1834 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -10,10 +10,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - name: Install libsqlite3-dev run: | sudo apt-get update From 4194d179024dd9bbd4c8b2d51b6575f370941f79 Mon Sep 17 00:00:00 2001 From: Sunli Date: Wed, 9 Sep 2020 15:27:45 +0800 Subject: [PATCH 2/3] Release 1.18.0 --- Cargo.toml | 6 +++--- benchmark/Cargo.toml | 2 +- derive/Cargo.toml | 4 ++-- docs/en/src/quickstart.md | 8 ++++---- docs/zh-CN/src/quickstart.md | 8 ++++---- integrations/actix-web/Cargo.toml | 4 ++-- integrations/lambda/Cargo.toml | 4 ++-- integrations/rocket/Cargo.toml | 4 ++-- integrations/tide/Cargo.toml | 4 ++-- integrations/warp/Cargo.toml | 4 ++-- parser/Cargo.toml | 2 +- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index febca7ce..29faf086 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql" -version = "1.17.21" +version = "1.18.0" authors = ["sunli "] 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-parser = { path = "parser", version = "1.17.3" } -async-graphql-derive = { path = "derive", version = "1.17.21" } +async-graphql-parser = { path = "parser", version = "1.18.0" } +async-graphql-derive = { path = "derive", version = "1.18.0" } anyhow = "1.0.26" thiserror = "1.0.11" async-trait = "0.1.30" diff --git a/benchmark/Cargo.toml b/benchmark/Cargo.toml index 5098bb46..de46be89 100644 --- a/benchmark/Cargo.toml +++ b/benchmark/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "graphql-benchmark" -version = "1.17.3" +version = "1.18.0" authors = ["sunli "] edition = "2018" diff --git a/derive/Cargo.toml b/derive/Cargo.toml index 38c09a42..43085c88 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-derive" -version = "1.17.21" +version = "1.18.0" authors = ["sunli "] 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 = "1.17.2" } +async-graphql-parser = { path = "../parser", version = "1.18.0" } proc-macro2 = "1.0.6" syn = { version = "1.0.20", features = ["full", "extra-traits"] } quote = "1.0.3" diff --git a/docs/en/src/quickstart.md b/docs/en/src/quickstart.md index 6c35b51b..4d1c39db 100644 --- a/docs/en/src/quickstart.md +++ b/docs/en/src/quickstart.md @@ -4,10 +4,10 @@ ```toml [dependencies] -async-graphql = "1.17.15" -async-graphql-actix-web = "1.17.3" # If you need to integrate into actix-web -async-graphql-warp = "1.17.3" # If you need to integrate into warp -async-graphql-tide = "1.17.9" # If you need to integrate into tide +async-graphql = "1.18.0" +async-graphql-actix-web = "1.18.0" # If you need to integrate into actix-web +async-graphql-warp = "1.18.0" # If you need to integrate into warp +async-graphql-tide = "1.18.0" # If you need to integrate into tide ``` ## Write a Schema diff --git a/docs/zh-CN/src/quickstart.md b/docs/zh-CN/src/quickstart.md index e508d908..cf2ab269 100644 --- a/docs/zh-CN/src/quickstart.md +++ b/docs/zh-CN/src/quickstart.md @@ -4,10 +4,10 @@ ```toml [dependencies] -async-graphql = "1.11.0" -async-graphql-actix-web = "1.3.0" # 如果你需要集成到Actix-web -async-graphql-warp = "1.3.0" # 如果你需要集成到Warp -async-graphql-tide = "1.2.0" # 如果你需要集成到Tide +async-graphql = "1.18.0" +async-graphql-actix-web = "1.18.0" # 如果你需要集成到Actix-web +async-graphql-warp = "1.18.0" # 如果你需要集成到Warp +async-graphql-tide = "1.18.0" # 如果你需要集成到Tide ``` ## 写一个Schema diff --git a/integrations/actix-web/Cargo.toml b/integrations/actix-web/Cargo.toml index 2c970ba2..fbecc0df 100644 --- a/integrations/actix-web/Cargo.toml +++ b/integrations/actix-web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-actix-web" -version = "1.17.18" +version = "1.18.0" authors = ["sunli "] 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 = "1.17.2" } +async-graphql = { path = "../..", version = "1.18.0" } actix-web = "2.0.0" actix-web-actors = "2.0.0" actix = "0.9.0" diff --git a/integrations/lambda/Cargo.toml b/integrations/lambda/Cargo.toml index ee3f98d5..de4ffae8 100644 --- a/integrations/lambda/Cargo.toml +++ b/integrations/lambda/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-lambda" -version = "1.14.0" +version = "1.18.0" authors = ["Sunli "] edition = "2018" description = "async-graphql for AWS Lambda" @@ -13,7 +13,7 @@ keywords = ["futures", "async", "graphql"] categories = ["network-programming", "asynchronous"] [dependencies] -async-graphql = { path = "../..", version = "1.17.2" } +async-graphql = { path = "../..", version = "1.18.0" } lambda_http = { git = "https://github.com/awslabs/aws-lambda-rust-runtime" } futures = "0.3.0" async-trait = "0.1.30" diff --git a/integrations/rocket/Cargo.toml b/integrations/rocket/Cargo.toml index d6344320..16d5ae71 100644 --- a/integrations/rocket/Cargo.toml +++ b/integrations/rocket/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-rocket" -version = "1.17.21" +version = "1.18.0" authors = ["Daniel Wiesenberg "] edition = "2018" description = "async-graphql for Rocket.rs" @@ -13,7 +13,7 @@ keywords = ["futures", "async", "graphql", "rocket"] categories = ["network-programming", "asynchronous"] [dependencies] -async-graphql = { path = "../..", version = "1.17.21" } +async-graphql = { path = "../..", version = "1.18.0" } 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 fed0aa29..a9e11306 100644 --- a/integrations/tide/Cargo.toml +++ b/integrations/tide/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-tide" -version = "1.17.9" +version = "1.18.0" 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 = "1.17.2" } +async-graphql = { path = "../..", version = "1.18.0" } tide = "0.13.0" async-trait = "0.1.36" serde_json = "1.0.56" diff --git a/integrations/warp/Cargo.toml b/integrations/warp/Cargo.toml index ce2766c6..1f00fa8b 100644 --- a/integrations/warp/Cargo.toml +++ b/integrations/warp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-warp" -version = "1.17.18" +version = "1.18.0" authors = ["sunli "] edition = "2018" description = "async-graphql for warp" @@ -13,7 +13,7 @@ keywords = ["futures", "async", "graphql"] categories = ["network-programming", "asynchronous"] [dependencies] -async-graphql = { path = "../..", version = "1.17.2" } +async-graphql = { path = "../..", version = "1.18.0" } warp = "0.2.2" futures = "0.3.0" bytes = "0.5.4" diff --git a/parser/Cargo.toml b/parser/Cargo.toml index e5c61890..52476d92 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-parser" -version = "1.17.3" +version = "1.18.0" authors = ["sunli "] edition = "2018" description = "GraphQL query parser for async-graphql" From a4a5847d4fe4333cad414c3b70450220947ba488 Mon Sep 17 00:00:00 2001 From: Sunli Date: Wed, 9 Sep 2020 18:42:10 +0800 Subject: [PATCH 3/3] Add context to ResolveInfo. #260 --- src/context.rs | 3 ++- src/extensions/mod.rs | 5 ++++- src/mutation_resolver.rs | 1 + src/resolver.rs | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/context.rs b/src/context.rs index 09e91025..114622b1 100644 --- a/src/context.rs +++ b/src/context.rs @@ -201,7 +201,8 @@ impl<'a> std::fmt::Display for QueryPathNode<'a> { } impl<'a> QueryPathNode<'a> { - pub(crate) fn field_name(&self) -> &str { + /// Get the current field name. + pub fn field_name(&self) -> &str { let mut p = self; loop { if let QueryPathSegment::Name(name) = &p.segment { diff --git a/src/extensions/mod.rs b/src/extensions/mod.rs index e1598dc8..63b30401 100644 --- a/src/extensions/mod.rs +++ b/src/extensions/mod.rs @@ -5,7 +5,7 @@ mod logger; mod tracing; use crate::context::{QueryPathNode, ResolveId}; -use crate::{Result, Variables}; +use crate::{Context, Result, Variables}; pub use self::apollo_tracing::ApolloTracing; pub use self::logger::Logger; @@ -28,6 +28,9 @@ pub struct ResolveInfo<'a> { /// Current path node, You can go through the entire path. pub path_node: &'a QueryPathNode<'a>, + /// Context + pub context: &'a Context<'a>, + /// Parent type pub parent_type: &'a str, diff --git a/src/mutation_resolver.rs b/src/mutation_resolver.rs index d293fc6e..5ff2d94e 100644 --- a/src/mutation_resolver.rs +++ b/src/mutation_resolver.rs @@ -64,6 +64,7 @@ fn do_resolve<'a, T: ObjectType + Send + Sync>( let resolve_info = ResolveInfo { resolve_id: ctx_field.resolve_id, path_node: ctx_field.path_node.as_ref().unwrap(), + context: &ctx_field, parent_type: &T::type_name(), return_type: match ctx_field .schema_env diff --git a/src/resolver.rs b/src/resolver.rs index c39fad66..0d39e80e 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -83,6 +83,7 @@ pub fn collect_fields<'a, T: ObjectType + Send + Sync>( let resolve_info = ResolveInfo { resolve_id: ctx_field.resolve_id, path_node: ctx_field.path_node.as_ref().unwrap(), + context: &ctx_field, parent_type: &T::type_name(), return_type: match ctx_field .schema_env