Skip to content

Commit 01ad6d0

Browse files
committed
add interfaces
1 parent 5f2784e commit 01ad6d0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

graphql_query_derive/src/interfaces.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ use unions::union_variants;
1010

1111
#[derive(Debug, PartialEq)]
1212
pub struct GqlInterface {
13+
pub description: Option<String>,
1314
pub implemented_by: HashSet<String>,
1415
pub name: String,
1516
pub fields: Vec<GqlObjectField>,
1617
}
1718

1819
impl GqlInterface {
19-
pub fn new(name: Cow<str>) -> GqlInterface {
20+
pub fn new(name: Cow<str>, description: Option<&str>) -> GqlInterface {
2021
GqlInterface {
22+
description: description.map(|d| d.to_owned()),
2123
name: name.into_owned(),
2224
implemented_by: HashSet::new(),
2325
fields: vec![],

graphql_query_derive/src/schema.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ impl ::std::convert::From<graphql_parser::schema::Document> for Schema {
279279
schema.unions.insert(union.name, GqlUnion(tys));
280280
}
281281
schema::TypeDefinition::Interface(interface) => {
282-
let mut iface = GqlInterface::new(interface.name.clone().into());
282+
let mut iface = GqlInterface::new(
283+
interface.name.clone().into(),
284+
interface.description.as_ref().map(|d| d.as_str()),
285+
);
283286
iface
284287
.fields
285288
.extend(interface.fields.iter().map(|f| GqlObjectField {
@@ -389,7 +392,10 @@ impl ::std::convert::From<::introspection_response::IntrospectionResponse> for S
389392
.insert(name.clone(), GqlObject::from_introspected_schema_json(ty));
390393
}
391394
Some(__TypeKind::INTERFACE) => {
392-
let mut iface = GqlInterface::new(name.clone().into());
395+
let mut iface = GqlInterface::new(
396+
name.clone().into(),
397+
ty.description.as_ref().map(|t| t.as_str()),
398+
);
393399
iface.fields.extend(
394400
ty.fields
395401
.clone()

0 commit comments

Comments
 (0)