From 80d6ec05ddea822b4baeefb896cbab0e6b558bed Mon Sep 17 00:00:00 2001 From: Sunli Date: Tue, 10 Nov 2020 11:46:56 +0800 Subject: [PATCH 1/2] Fix #322. --- parser/src/graphql.pest | 4 ++-- parser/src/parse/service.rs | 16 +++++++++++++++- parser/src/types/service.rs | 2 ++ parser/tests/services/implements.graphql | 4 ++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/parser/src/graphql.pest b/parser/src/graphql.pest index 5fcc7fd3..4d42bbb1 100644 --- a/parser/src/graphql.pest +++ b/parser/src/graphql.pest @@ -47,8 +47,8 @@ object_type = { implements_interfaces = { "implements" ~ "&"? ~ name ~ ("&" ~ name)* } interface_type = { - string? ~ "interface" ~ name ~ const_directives? ~ fields_definition? - | extend ~ "interface" ~ name ~ (const_directives? ~ fields_definition | const_directives) + string? ~ "interface" ~ name ~ implements_interfaces? ~ const_directives? ~ fields_definition? + | extend ~ "interface" ~ name ~ implements_interfaces? ~ (const_directives? ~ fields_definition | const_directives) } fields_definition = { "{" ~ field_definition+ ~ "}" } diff --git a/parser/src/parse/service.rs b/parser/src/parse/service.rs index 7ad49f87..e79e8bce 100644 --- a/parser/src/parse/service.rs +++ b/parser/src/parse/service.rs @@ -149,12 +149,26 @@ fn parse_type_definition( ) } Rule::interface_type => { + let implements = parse_if_rule(&mut pairs, Rule::implements_interfaces, |pair| { + debug_assert_eq!(pair.as_rule(), Rule::implements_interfaces); + + pair.into_inner() + .map(|pair| parse_name(pair, pc)) + .collect::>() + })?; + let directives = parse_opt_const_directives(&mut pairs, pc)?; let fields = parse_if_rule(&mut pairs, Rule::fields_definition, |pair| { parse_fields_definition(pair, pc) })? .unwrap_or_default(); - (directives, TypeKind::Interface(InterfaceType { fields })) + ( + directives, + TypeKind::Interface(InterfaceType { + implements: implements.unwrap_or_default(), + fields, + }), + ) } Rule::union_type => { let directives = parse_opt_const_directives(&mut pairs, pc)?; diff --git a/parser/src/types/service.rs b/parser/src/types/service.rs index 185d2106..2a3e81f5 100644 --- a/parser/src/types/service.rs +++ b/parser/src/types/service.rs @@ -112,6 +112,8 @@ pub struct FieldDefinition { /// [Reference](https://spec.graphql.org/June2018/#InterfaceType). #[derive(Debug, Clone)] pub struct InterfaceType { + /// The interfaces implemented by the interface. + pub implements: Vec>, /// The fields of the interface type. pub fields: Vec>, } diff --git a/parser/tests/services/implements.graphql b/parser/tests/services/implements.graphql index a84b001a..473bc7aa 100644 --- a/parser/tests/services/implements.graphql +++ b/parser/tests/services/implements.graphql @@ -1,3 +1,7 @@ type Type1 implements IOne type Type1 implements IOne & ITwo + +interface Type1 implements IOne + +interface Type1 implements IOne & ITwo From 666154a62f41630787448b0e8970f41d0d800af5 Mon Sep 17 00:00:00 2001 From: Sunli Date: Tue, 10 Nov 2020 11:47:48 +0800 Subject: [PATCH 2/2] Release 2.1.1 async-graphql@2.1.1 async-graphql-actix-web@2.1.1 async-graphql-derive@2.1.1 async-graphql-parser@2.1.1 async-graphql-tide@2.1.1 async-graphql-warp@2.1.1 Generated by cargo-workspaces --- Cargo.toml | 6 +++--- derive/Cargo.toml | 4 ++-- integrations/actix-web/Cargo.toml | 4 ++-- integrations/rocket/Cargo.toml | 2 +- integrations/tide/Cargo.toml | 4 ++-- integrations/warp/Cargo.toml | 4 ++-- parser/Cargo.toml | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 47e0683f..0e15aded 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql" -version = "2.1.0" +version = "2.1.1" authors = ["sunli ", "Koxiaet"] edition = "2018" description = "A GraphQL server library implemented in Rust" @@ -36,9 +36,9 @@ string_number = ["num-traits"] nightly = [] [dependencies] -async-graphql-derive = { path = "derive", version = "=2.0.16" } +async-graphql-derive = { path = "derive", version = "=2.1.1" } async-graphql-value = { path = "value", version = "=2.0.5" } -async-graphql-parser = { path = "parser", version = "=2.0.8" } +async-graphql-parser = { path = "parser", version = "=2.1.1" } async-stream = "0.3" async-trait = "0.1.41" diff --git a/derive/Cargo.toml b/derive/Cargo.toml index ab9ede09..a48089b7 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-derive" -version = "2.0.16" +version = "2.1.1" authors = ["sunli ", "Koxiaet"] edition = "2018" description = "Macros for async-graphql" @@ -15,7 +15,7 @@ categories = ["network-programming", "asynchronous"] proc-macro = true [dependencies] -async-graphql-parser = { path = "../parser", version = "=2.0.8" } +async-graphql-parser = { path = "../parser", version = "=2.1.1" } proc-macro2 = "1.0.6" syn = { version = "1.0.44", features = ["full", "extra-traits", "visit-mut"] } quote = "1.0.3" diff --git a/integrations/actix-web/Cargo.toml b/integrations/actix-web/Cargo.toml index eb229527..8beed4e8 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.1.0" +version = "2.1.1" authors = ["sunli ", "Koxiaet"] edition = "2018" description = "async-graphql for actix-web" @@ -12,7 +12,7 @@ keywords = ["futures", "async", "graphql"] categories = ["network-programming", "asynchronous"] [dependencies] -async-graphql = { path = "../..", version = "=2.1.0" } +async-graphql = { path = "../..", version = "=2.1.1" } actix = "0.10.0" actix-http = "2.0.0" diff --git a/integrations/rocket/Cargo.toml b/integrations/rocket/Cargo.toml index 6bb0a7c6..d2b5a534 100644 --- a/integrations/rocket/Cargo.toml +++ b/integrations/rocket/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["futures", "async", "graphql", "rocket"] categories = ["network-programming", "asynchronous"] [dependencies] -async-graphql = { path = "../..", version = "=2.1.0" } +async-graphql = { path = "../..", version = "=2.1.1" } rocket = { git = "https://github.com/SergioBenitez/Rocket/", rev = "0c150c2", default-features = false } # TODO: Change to Cargo crate when Rocket 0.5.0 is released serde = "1.0.117" diff --git a/integrations/tide/Cargo.toml b/integrations/tide/Cargo.toml index 5448b1cd..78f3e8bc 100644 --- a/integrations/tide/Cargo.toml +++ b/integrations/tide/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-tide" -version = "2.1.0" +version = "2.1.1" authors = ["vkill "] edition = "2018" description = "async-graphql for tide" @@ -12,7 +12,7 @@ keywords = ["futures", "async", "graphql"] categories = ["network-programming", "asynchronous"] [dependencies] -async-graphql = { path = "../..", version = "=2.1.0" } +async-graphql = { path = "../..", version = "=2.1.1" } tide = { version = "0.14.0", default-features = false, features = ["h1-server"] } diff --git a/integrations/warp/Cargo.toml b/integrations/warp/Cargo.toml index a14eec0f..fd23f858 100644 --- a/integrations/warp/Cargo.toml +++ b/integrations/warp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-warp" -version = "2.1.0" +version = "2.1.1" authors = ["sunli ", "Koxiaet"] edition = "2018" description = "async-graphql for warp" @@ -12,7 +12,7 @@ keywords = ["futures", "async", "graphql"] categories = ["network-programming", "asynchronous"] [dependencies] -async-graphql = { path = "../..", version = "=2.1.0" } +async-graphql = { path = "../..", version = "=2.1.1" } warp = { version = "0.2.5", default-features = false, features = ["websocket"] } futures-util = { version = "0.3.6", default-features = false } diff --git a/parser/Cargo.toml b/parser/Cargo.toml index 81456886..fd283711 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-graphql-parser" -version = "2.0.8" +version = "2.1.1" authors = ["sunli ", "Koxiaet"] edition = "2018" description = "GraphQL query parser for async-graphql"