Skip to content

Commit

Permalink
export: say when an object implements an interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijah Stone authored and burner committed Mar 31, 2021
1 parent 98e3bd0 commit 3ddac19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion source/graphql/schema/toschemafile.d
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,18 @@ void typeImpl(Out)(ref Out o, TraceableType type, in TraceableType[string] tab)
}
}

string implementsStr = "";
string typestr = "type";
if(auto unio = cast(GQLDUnion)map) {
typestr = "union";
} else if(auto obj = cast(GQLDObject)map) {
typestr = typeKindToString(obj.typeKind);
if(obj.base && obj.base.typeKind == TypeKind.INTERFACE) {
implementsStr = " implements " ~ obj.base.name;
}
}

formIndent(o, 0, "%s %s {", typestr, map.name);
formIndent(o, 0, "%s %s%s {", typestr, map.name, implementsStr);
dumpMem(map.name == "mutationType");
formIndent(o, 0, "}");

Expand Down
4 changes: 2 additions & 2 deletions test/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ schema {
subscription: subscriptionType
}
scalar Date
type Android {
type Android implements Character {
ships: Starship
series: [Series!]!
id: Int!
Expand Down Expand Up @@ -109,7 +109,7 @@ type queryType {
starshipDoesNotExist: Starship!
character(id: Int!): Character
}
type Humanoid {
type Humanoid implements Character {
ships: Starship
series: [Series!]!
id: Int!
Expand Down

0 comments on commit 3ddac19

Please sign in to comment.