Skip to content

Commit be24fdc

Browse files
mrdon-atlassianbbakerman
authored andcommitted
Fix introspection processing missing implements
1 parent e98b5fa commit be24fdc

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/main/java/graphql/introspection/IntrospectionResultToSchema.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Collections;
3131
import java.util.List;
3232
import java.util.Map;
33+
import java.util.stream.Collectors;
3334

3435
import static graphql.Assert.assertNotNull;
3536
import static graphql.Assert.assertShouldNeverHappen;
@@ -206,6 +207,13 @@ ObjectTypeDefinition createObject(Map<String, Object> input) {
206207

207208
ObjectTypeDefinition objectTypeDefinition = new ObjectTypeDefinition((String) input.get("name"));
208209
objectTypeDefinition.setComments(toComment((String) input.get("description")));
210+
if (input.containsKey("interfaces")) {
211+
objectTypeDefinition.getImplements().addAll(
212+
((List<Map<String, Object>>)input.get("interfaces")).stream()
213+
.map(this::createTypeIndirection)
214+
.collect(Collectors.toList())
215+
);
216+
}
209217
List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("fields");
210218

211219
objectTypeDefinition.getFieldDefinitions().addAll(createFields(fields));

src/test/groovy/graphql/introspection/IntrospectionResultToSchemaTest.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ class IntrospectionResultToSchemaTest extends Specification {
7474
}
7575
],
7676
"inputFields": null,
77-
"interfaces": [],
77+
"interfaces": [{
78+
"kind": "INTERFACE",
79+
"name": "Query",
80+
"ofType": null
81+
}],
7882
"enumValues": null,
7983
"possibleTypes": null
8084
}
@@ -87,7 +91,7 @@ class IntrospectionResultToSchemaTest extends Specification {
8791
def result = astPrinter.printAst(objectTypeDefinition)
8892

8993
then:
90-
result == """type QueryType {
94+
result == """type QueryType implements Query {
9195
hero(
9296
#comment about episode
9397
episode: Episode
@@ -437,7 +441,7 @@ enum Episode {
437441
}
438442
439443
#A humanoid creature in the Star Wars universe.
440-
type Human {
444+
type Human implements Character {
441445
#The id of the human.
442446
id: String!
443447
#The name of the human.
@@ -451,7 +455,7 @@ type Human {
451455
}
452456
453457
#A mechanical creature in the Star Wars universe.
454-
type Droid {
458+
type Droid implements Character {
455459
#The id of the droid.
456460
id: String!
457461
#The name of the droid.

0 commit comments

Comments
 (0)