Add a specification to implement the interface to the interface.

This commit is contained in:
Danuel 2020-07-05 01:35:25 +09:00
parent 0e4cf86884
commit 67251faed7
6 changed files with 18 additions and 1 deletions

View File

@ -46,7 +46,7 @@ arguments_definition = { "(" ~ input_value_definition* ~ ")" }
field_definition = { string? ~ name ~ arguments_definition? ~ ":" ~ type_ ~ directives? }
fields_definition = { "{" ~ field_definition* ~ "}" }
object_type_definition = { string? ~ extend? ~ "type" ~ name ~ implements_interfaces? ~ directives? ~ fields_definition? }
interface_type_definition = { string? ~ extend? ~ "interface" ~ name ~ directives? ~ fields_definition? }
interface_type_definition = { string? ~ extend? ~ "interface" ~ name ~ implements_interfaces? ~ directives? ~ fields_definition? }
union_member_types = { "=" ~ "|"? ~ name ~ ("|" ~ name)* }
union_type_definition = { string? ~ extend? ~ "union" ~ name ~ directives? ~ union_member_types? }
enum_value_definition = { string? ~ name ~ directives? }

View File

@ -93,6 +93,7 @@ pub struct InterfaceType {
pub extend: bool,
pub description: Option<Positioned<String>>,
pub name: Positioned<String>,
pub implements_interfaces: Vec<Positioned<String>>,
pub directives: Vec<Positioned<Directive>>,
pub fields: Vec<Positioned<Field>>,
}

View File

@ -475,6 +475,7 @@ fn parse_interface_type(
let mut description = None;
let mut extend = false;
let mut name = None;
let mut implements_interfaces = None;
let mut directives = None;
let mut fields = None;
@ -485,6 +486,9 @@ fn parse_interface_type(
}
Rule::extend => extend = true,
Rule::name => name = Some(Positioned::new(pair.as_str().to_string(), pc.step(&pair))),
Rule::implements_interfaces => {
implements_interfaces = Some(parse_implements_interfaces(pair, pc)?)
}
Rule::directives => directives = Some(parse_directives(pair, pc)?),
Rule::fields_definition => fields = Some(parse_fields_definition(pair, pc)?),
_ => unreachable!(),
@ -496,6 +500,7 @@ fn parse_interface_type(
extend,
description,
name: name.unwrap(),
implements_interfaces: implements_interfaces.unwrap_or_default(),
directives: directives.unwrap_or_default(),
fields: fields.unwrap_or_default(),
},

View File

@ -1,3 +1,7 @@
type Type1 implements IOne
type Type1 implements IOne & ITwo
interface Type1 implements IOne
interface Type1 implements IOne & ITwo

View File

@ -1,2 +1,5 @@
type Type1 implements & IOne & ITwo
type Type2 implements & IOne
interface Type1 implements & IOne & ITwo
interface Type2 implements & IOne

View File

@ -1,3 +1,7 @@
type Type1 implements IOne & ITwo
type Type2 implements IOne
interface Type1 implements IOne & ITwo
interface Type2 implements IOne