From 35ccfcb3becb101de80214de19044e4eab6a147a Mon Sep 17 00:00:00 2001 From: Franklin Wang Date: Fri, 13 Dec 2024 17:11:02 +1100 Subject: [PATCH] Delete shared type rename patch as new blueprint handles it properly --- .../java/graphql/nadel/NadelExecutionHints.kt | 11 ++--------- .../transform/NadelServiceTypeFilterTransform.kt | 3 --- .../transform/NadelTypeRenameResultTransform.kt | 14 +------------- .../transform/query/NadelQueryTransformer.kt | 10 ++-------- .../nadel/tests/hooks/shared-types-rename.kt | 15 ++------------- 5 files changed, 7 insertions(+), 46 deletions(-) diff --git a/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt b/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt index 4c5799930..4b87046ff 100644 --- a/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt +++ b/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt @@ -3,7 +3,6 @@ package graphql.nadel import graphql.nadel.hints.AllDocumentVariablesHint import graphql.nadel.hints.LegacyOperationNamesHint import graphql.nadel.hints.NadelDeferSupportHint -import graphql.nadel.hints.NadelSharedTypeRenamesHint import graphql.nadel.hints.NadelShortCircuitEmptyQueryHint import graphql.nadel.hints.NadelVirtualTypeSupportHint import graphql.nadel.hints.NewResultMergerAndNamespacedTypename @@ -13,7 +12,6 @@ data class NadelExecutionHints( val allDocumentVariablesHint: AllDocumentVariablesHint, val newResultMergerAndNamespacedTypename: NewResultMergerAndNamespacedTypename, val deferSupport: NadelDeferSupportHint, - val sharedTypeRenames: NadelSharedTypeRenamesHint, val shortCircuitEmptyQuery: NadelShortCircuitEmptyQueryHint, val virtualTypeSupport: NadelVirtualTypeSupportHint, ) { @@ -33,7 +31,6 @@ data class NadelExecutionHints( private var newResultMergerAndNamespacedTypename = NewResultMergerAndNamespacedTypename { false } private var deferSupport = NadelDeferSupportHint { false } private var shortCircuitEmptyQuery = NadelShortCircuitEmptyQueryHint { false } - private var sharedTypeRenames = NadelSharedTypeRenamesHint { false } private var virtualTypeSupport = NadelVirtualTypeSupportHint { false } constructor() @@ -42,7 +39,9 @@ data class NadelExecutionHints( legacyOperationNames = nadelExecutionHints.legacyOperationNames allDocumentVariablesHint = nadelExecutionHints.allDocumentVariablesHint newResultMergerAndNamespacedTypename = nadelExecutionHints.newResultMergerAndNamespacedTypename + deferSupport = nadelExecutionHints.deferSupport shortCircuitEmptyQuery = nadelExecutionHints.shortCircuitEmptyQuery + virtualTypeSupport = nadelExecutionHints.virtualTypeSupport } fun legacyOperationNames(flag: LegacyOperationNamesHint): Builder { @@ -70,11 +69,6 @@ data class NadelExecutionHints( return this } - fun sharedTypeRenames(flag: NadelSharedTypeRenamesHint): Builder { - sharedTypeRenames = flag - return this - } - fun virtualTypeSupport(flag: NadelVirtualTypeSupportHint): Builder { virtualTypeSupport = flag return this @@ -86,7 +80,6 @@ data class NadelExecutionHints( allDocumentVariablesHint, newResultMergerAndNamespacedTypename, deferSupport, - sharedTypeRenames, shortCircuitEmptyQuery, virtualTypeSupport, ) diff --git a/lib/src/main/java/graphql/nadel/engine/transform/NadelServiceTypeFilterTransform.kt b/lib/src/main/java/graphql/nadel/engine/transform/NadelServiceTypeFilterTransform.kt index 7b259d84a..2fa8fa5b8 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/NadelServiceTypeFilterTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/NadelServiceTypeFilterTransform.kt @@ -94,7 +94,6 @@ class NadelServiceTypeFilterTransform : NadelTransform { .filter { objectTypeName -> isTypeOwnedByService( objectTypeName, - executionContext, service, executionBlueprint, ) @@ -119,7 +118,6 @@ class NadelServiceTypeFilterTransform : NadelTransform { private fun isTypeOwnedByService( objectTypeName: String, - executionContext: NadelExecutionContext, service: Service, executionBlueprint: NadelOverallExecutionBlueprint, ): Boolean { @@ -133,7 +131,6 @@ class NadelServiceTypeFilterTransform : NadelTransform { // concat 1 giant set and then check return objectTypeName in typeNamesOwnedByService || objectTypeName in underlyingTypeNamesOwnedByService - || (executionContext.hints.sharedTypeRenames(service) && executionBlueprint.getUnderlyingTypeName(objectTypeName) in underlyingTypeNamesOwnedByService) } override suspend fun transformField( diff --git a/lib/src/main/java/graphql/nadel/engine/transform/NadelTypeRenameResultTransform.kt b/lib/src/main/java/graphql/nadel/engine/transform/NadelTypeRenameResultTransform.kt index 41e3810a2..e56f2054a 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/NadelTypeRenameResultTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/NadelTypeRenameResultTransform.kt @@ -92,22 +92,10 @@ internal class NadelTypeRenameResultTransform : NadelTransform { ?: overallTypeName } - val typeName: String = if (executionContext.hints.sharedTypeRenames(service)) { - if (overallField.objectTypeNames.contains(overallTypeName)) { - overallTypeName - } else { - overallField.objectTypeNames.singleOrNull { - executionBlueprint.getRename(it)?.underlyingName == underlyingTypeName - } ?: overallTypeName - } - } else { - overallTypeName - } - NadelResultInstruction.Set( subject = parentNode, key = NadelResultKey(overallField.resultKey), - newValue = JsonNode(typeName), + newValue = JsonNode(overallTypeName), ) } } diff --git a/lib/src/main/java/graphql/nadel/engine/transform/query/NadelQueryTransformer.kt b/lib/src/main/java/graphql/nadel/engine/transform/query/NadelQueryTransformer.kt index 1abeeba51..e985d57cd 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/query/NadelQueryTransformer.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/query/NadelQueryTransformer.kt @@ -180,14 +180,8 @@ class NadelQueryTransformer private constructor( } private fun getUnderlyingTypeNames(objectTypeNames: Collection): List { - return if (executionContext.hints.sharedTypeRenames(service)) { - objectTypeNames.map { - executionBlueprint.getUnderlyingTypeName(overallTypeName = it) - } - } else { - objectTypeNames.map { - executionBlueprint.getUnderlyingTypeName(service, overallTypeName = it) - } + return objectTypeNames.map { + executionBlueprint.getUnderlyingTypeName(service, overallTypeName = it) } } diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/shared-types-rename.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/shared-types-rename.kt index 2d38c4973..ca88de7b0 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/shared-types-rename.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/shared-types-rename.kt @@ -1,20 +1,9 @@ package graphql.nadel.tests.hooks -import graphql.nadel.NadelExecutionInput import graphql.nadel.tests.EngineTestHook import graphql.nadel.tests.UseHook -abstract class `shared-types-rename` : EngineTestHook { - override fun makeExecutionInput( - builder: NadelExecutionInput.Builder, - ): NadelExecutionInput.Builder { - return builder.transformExecutionHints { - it.sharedTypeRenames { - true - } - } - } -} +abstract class `shared-types-rename` : EngineTestHook @UseHook -class `renamed-type-in-union-declared-in-another-service` : `shared-types-rename`() \ No newline at end of file +class `renamed-type-in-union-declared-in-another-service` : `shared-types-rename`()