Skip to content

Commit

Permalink
Delete shared type rename patch as new blueprint handles it properly
Browse files Browse the repository at this point in the history
  • Loading branch information
gnawf committed Dec 18, 2024
1 parent 157423c commit d7f209e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 46 deletions.
11 changes: 2 additions & 9 deletions lib/src/main/java/graphql/nadel/NadelExecutionHints.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
) {
Expand All @@ -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()
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -86,7 +80,6 @@ data class NadelExecutionHints(
allDocumentVariablesHint,
newResultMergerAndNamespacedTypename,
deferSupport,
sharedTypeRenames,
shortCircuitEmptyQuery,
virtualTypeSupport,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class NadelServiceTypeFilterTransform : NadelTransform<State> {
.filter { objectTypeName ->
isTypeOwnedByService(
objectTypeName,
executionContext,
service,
executionBlueprint,
)
Expand All @@ -119,7 +118,6 @@ class NadelServiceTypeFilterTransform : NadelTransform<State> {

private fun isTypeOwnedByService(
objectTypeName: String,
executionContext: NadelExecutionContext,
service: Service,
executionBlueprint: NadelOverallExecutionBlueprint,
): Boolean {
Expand All @@ -133,7 +131,6 @@ class NadelServiceTypeFilterTransform : NadelTransform<State> {
// 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,10 @@ internal class NadelTypeRenameResultTransform : NadelTransform<State> {
?: 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),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,8 @@ class NadelQueryTransformer private constructor(
}

private fun getUnderlyingTypeNames(objectTypeNames: Collection<String>): List<String> {
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)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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`()
class `renamed-type-in-union-declared-in-another-service` : `shared-types-rename`()

0 comments on commit d7f209e

Please sign in to comment.