File tree 2 files changed +11
-10
lines changed
graphql-kotlin-schema-generator/src
main/kotlin/com/expediagroup/graphql/generator
test/kotlin/com/expediagroup/graphql/generator 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -90,14 +90,15 @@ open class SchemaGenerator(internal val config: SchemaGeneratorConfig) {
90
90
* This function is recursive because while generating the additionalTypes it is possible to create additional types that need to be processed.
91
91
*/
92
92
protected open fun generateAdditionalTypes (): Set <GraphQLType > {
93
- val currentlyProcessedTypes = this .additionalTypes.toSet()
94
- this .additionalTypes.clear()
95
- val graphqlTypes = currentlyProcessedTypes.map { generateGraphQLType(this , it) }.toSet()
93
+ val currentlyProcessedTypes = mutableSetOf<KType >()
94
+ val graphqlTypes = mutableSetOf<GraphQLType >()
95
+ do {
96
+ currentlyProcessedTypes.addAll(this .additionalTypes)
97
+ this .additionalTypes.clear()
98
+ graphqlTypes.addAll(currentlyProcessedTypes.map { generateGraphQLType(this , it) })
99
+ currentlyProcessedTypes.clear()
100
+ } while (this .additionalTypes.isNotEmpty())
96
101
97
- return if (this .additionalTypes.isNotEmpty()) {
98
- graphqlTypes.plus(generateAdditionalTypes())
99
- } else {
100
- graphqlTypes
101
- }
102
+ return graphqlTypes.toSet()
102
103
}
103
104
}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class SchemaGeneratorTest {
48
48
val result = generator.generateCustomAdditionalTypes()
49
49
50
50
assertEquals(1 , result.size)
51
- assertEquals(" SomeObjectWithAnnotaiton !" , result.first().deepName)
51
+ assertEquals(" SomeObjectWithAnnotation !" , result.first().deepName)
52
52
}
53
53
54
54
class CustomSchemaGenerator (config : SchemaGeneratorConfig ) : SchemaGenerator(config) {
@@ -61,5 +61,5 @@ class SchemaGeneratorTest {
61
61
annotation class MyOtherCustomAnnotation
62
62
63
63
@MyCustomAnnotation
64
- data class SomeObjectWithAnnotaiton (val name : String )
64
+ data class SomeObjectWithAnnotation (val name : String )
65
65
}
You can’t perform that action at this time.
0 commit comments