You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend single-operation reuse logic to work across multiple operations
- Modify generateCustomClassName to use cross-operation reuse logic for shared types
- Add isCachedTypeApplicableForSharedType function for selection set verification
- Update selection set tracking to work with type variants across operations
- Create cross_operation_reuse test case with Operation1 and Operation2
- Generate exactly 3 shared types (ComplexObject, ComplexObject2, ComplexObject3)
- Maintain backward compatibility with existing reuse_types functionality
- Fix missing ScalarTypeDefinition import that caused compilation errors
- Verify functionality with gradle-client and maven-client examples
Co-Authored-By: Arthur Poon <[email protected]>
Copy file name to clipboardExpand all lines: plugins/client/graphql-kotlin-client-generator/src/main/kotlin/com/expediagroup/graphql/plugin/client/generator/GraphQLClientGeneratorContext.kt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,7 @@ data class GraphQLClientGeneratorContext(
56
56
val classNameCache:MutableMap<String, MutableList<ClassName>> =mutableMapOf()
57
57
val typeToSelectionSetMap:MutableMap<String, Set<String>> =mutableMapOf()
58
58
val responseTypeToSelectionSetMap:MutableMap<String, MutableSet<Selection<*>>> =mutableMapOf()
59
+
val sharedTypeVariantToSelectionSetMap:MutableMap<String, Set<String>> =mutableMapOf()
59
60
60
61
// usage tracking for shared response types
61
62
val typeUsageCount:MutableMap<String, Int> =mutableMapOf()
Copy file name to clipboardExpand all lines: plugins/client/graphql-kotlin-client-generator/src/main/kotlin/com/expediagroup/graphql/plugin/client/generator/types/generateTypeName.kt
Copy file name to clipboardExpand all lines: plugins/client/graphql-kotlin-client-generator/src/test/kotlin/com/expediagroup/graphql/plugin/client/generator/SharedResponseTypesTest.kt
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -95,4 +95,32 @@ class SharedResponseTypesTest {
95
95
)
96
96
assertFalse(configExplicitlyDisabled.useSharedResponseTypes, "Expected useSharedResponseTypes to be false when explicitly disabled")
97
97
}
98
+
99
+
@Test
100
+
fun`verify cross-operation type reuse generates exactly 3 shared types`() {
101
+
val configWithSharedTypes =GraphQLClientGeneratorConfig(
0 commit comments