From c32fbedb3c4f4a364e6ae5113026bf4db89d22ca Mon Sep 17 00:00:00 2001 From: Artyom Emelyanenko Date: Mon, 27 Jul 2026 17:26:46 +1000 Subject: [PATCH] Remove virtual type support hint --- .../java/graphql/nadel/NadelExecutionHints.kt | 10 - .../hydration/NadelHydrationFieldsBuilder.kt | 9 +- .../hydration/NadelHydrationTransform.kt | 1 - .../hints/NadelVirtualTypeSupportHint.kt | 10 - .../HydrationRemainingArgumentsTest.kt | 1 - ...ticHydrationAndPolymorphicHydrationTest.kt | 1 - .../statics/StaticHydrationNestedErrorTest.kt | 1 - ...StaticHydrationOverlappingHydrationTest.kt | 1 - .../statics/StaticHydrationScalarFieldTest.kt | 1 - .../hydration/statics/StaticHydrationTest.kt | 1 - .../StaticHydrationVirtualTypeHintOffTest.kt | 202 ------------------ ...HydrationVirtualTypeHintOffTestSnapshot.kt | 70 ------ .../schema/CustomHydrationDirectiveTest.kt | 6 - 13 files changed, 3 insertions(+), 311 deletions(-) delete mode 100644 lib/src/main/java/graphql/nadel/hints/NadelVirtualTypeSupportHint.kt delete mode 100644 test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTest.kt delete mode 100644 test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTestSnapshot.kt diff --git a/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt b/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt index 82f15fc7a..488b98ec3 100644 --- a/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt +++ b/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt @@ -13,7 +13,6 @@ import graphql.nadel.hints.NadelReachableUnderlyingServiceTypesHint import graphql.nadel.hints.NadelShadowUnderlyingTypeNameInvestigation import graphql.nadel.hints.NadelSharedTypeRenamesHint import graphql.nadel.hints.NadelShortCircuitEmptyQueryHint -import graphql.nadel.hints.NadelVirtualTypeSupportHint import graphql.nadel.hints.NewResultMergerAndNamespacedTypename data class NadelExecutionHints( @@ -23,7 +22,6 @@ data class NadelExecutionHints( val deferSupport: NadelDeferSupportHint, val sharedTypeRenames: NadelSharedTypeRenamesHint, val shortCircuitEmptyQuery: NadelShortCircuitEmptyQueryHint, - val virtualTypeSupport: NadelVirtualTypeSupportHint, val executeOnEngineSchema: NadelExecuteOnEngineSchemaHint, val hydrationFilterObjectTypes: NadelHydrationFilterObjectTypesHint, val hydrationExecutableSourceFields: NadelHydrationExecutableSourceFields, @@ -50,7 +48,6 @@ data class NadelExecutionHints( private var deferSupport = NadelDeferSupportHint { false } private var shortCircuitEmptyQuery = NadelShortCircuitEmptyQueryHint { false } private var sharedTypeRenames = NadelSharedTypeRenamesHint { false } - private var virtualTypeSupport = NadelVirtualTypeSupportHint { false } private var executeOnEngineSchema = NadelExecuteOnEngineSchemaHint { false } private var hydrationFilterObjectTypes = NadelHydrationFilterObjectTypesHint { false } private var hydrationExecutableSourceFields = NadelHydrationExecutableSourceFields { false } @@ -69,7 +66,6 @@ data class NadelExecutionHints( deferSupport = nadelExecutionHints.deferSupport shortCircuitEmptyQuery = nadelExecutionHints.shortCircuitEmptyQuery sharedTypeRenames = nadelExecutionHints.sharedTypeRenames - virtualTypeSupport = nadelExecutionHints.virtualTypeSupport executeOnEngineSchema = nadelExecutionHints.executeOnEngineSchema hydrationFilterObjectTypes = nadelExecutionHints.hydrationFilterObjectTypes hydrationExecutableSourceFields = nadelExecutionHints.hydrationExecutableSourceFields @@ -110,11 +106,6 @@ data class NadelExecutionHints( return this } - fun virtualTypeSupport(flag: NadelVirtualTypeSupportHint): Builder { - virtualTypeSupport = flag - return this - } - fun executeOnEngineSchema(flag: NadelExecuteOnEngineSchemaHint): Builder { executeOnEngineSchema = flag return this @@ -163,7 +154,6 @@ data class NadelExecutionHints( deferSupport, sharedTypeRenames, shortCircuitEmptyQuery, - virtualTypeSupport, executeOnEngineSchema, hydrationFilterObjectTypes, hydrationExecutableSourceFields, diff --git a/lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationFieldsBuilder.kt b/lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationFieldsBuilder.kt index 47a37568f..424e3156c 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationFieldsBuilder.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationFieldsBuilder.kt @@ -23,7 +23,6 @@ import graphql.normalized.NormalizedInputValue internal object NadelHydrationFieldsBuilder { fun makeBackingQueries( executionContext: NadelExecutionContext, - service: Service, instruction: NadelHydrationFieldInstruction, aliasHelper: NadelAliasHelper, virtualField: ExecutableNormalizedField, @@ -53,11 +52,9 @@ internal object NadelHydrationFieldsBuilder { } // Fix types for virtual fields .onEach { field -> - if (executionContext.hints.virtualTypeSupport(service)) { - setBackingObjectTypeNames(instruction, field) - field.traverseSubTree { child -> - setBackingObjectTypeNames(instruction, child) - } + setBackingObjectTypeNames(instruction, field) + field.traverseSubTree { child -> + setBackingObjectTypeNames(instruction, child) } } } diff --git a/lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationTransform.kt b/lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationTransform.kt index 3de564d39..88d2675b8 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationTransform.kt @@ -336,7 +336,6 @@ internal class NadelHydrationTransform( val backingQueries = NadelHydrationFieldsBuilder.makeBackingQueries( executionContext = executionContext, - service = state.virtualFieldService, instruction = instruction, aliasHelper = state.aliasHelper, virtualField = virtualField, diff --git a/lib/src/main/java/graphql/nadel/hints/NadelVirtualTypeSupportHint.kt b/lib/src/main/java/graphql/nadel/hints/NadelVirtualTypeSupportHint.kt deleted file mode 100644 index 0922f5357..000000000 --- a/lib/src/main/java/graphql/nadel/hints/NadelVirtualTypeSupportHint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package graphql.nadel.hints - -import graphql.nadel.Service - -fun interface NadelVirtualTypeSupportHint { - /** - * Determines whether virtual type & some of the new hydration work is enabled. - */ - operator fun invoke(service: Service): Boolean -} diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/HydrationRemainingArgumentsTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/HydrationRemainingArgumentsTest.kt index 149ebbd32..c3653cf0d 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/HydrationRemainingArgumentsTest.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/HydrationRemainingArgumentsTest.kt @@ -173,7 +173,6 @@ class HydrationRemainingArgumentsTest : NadelIntegrationTest( ) { override fun makeExecutionHints(): NadelExecutionHints.Builder { return super.makeExecutionHints() - .virtualTypeSupport { true } .shortCircuitEmptyQuery { true } } } diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationAndPolymorphicHydrationTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationAndPolymorphicHydrationTest.kt index 750cf1c42..5a781d30a 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationAndPolymorphicHydrationTest.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationAndPolymorphicHydrationTest.kt @@ -262,7 +262,6 @@ class StaticHydrationAndPolymorphicHydrationTest : NadelIntegrationTest( ) { override fun makeExecutionHints(): NadelExecutionHints.Builder { return super.makeExecutionHints() - .virtualTypeSupport { true } .shortCircuitEmptyQuery { true } } diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationNestedErrorTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationNestedErrorTest.kt index c3fb0cbe5..2d828e55a 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationNestedErrorTest.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationNestedErrorTest.kt @@ -210,7 +210,6 @@ class StaticHydrationNestedErrorTest : NadelIntegrationTest( ) { override fun makeExecutionHints(): NadelExecutionHints.Builder { return super.makeExecutionHints() - .virtualTypeSupport { true } .shortCircuitEmptyQuery { true } } diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationOverlappingHydrationTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationOverlappingHydrationTest.kt index 9d34da822..9ef85861a 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationOverlappingHydrationTest.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationOverlappingHydrationTest.kt @@ -257,7 +257,6 @@ class StaticHydrationOverlappingHydrationTest : NadelIntegrationTest( ) { override fun makeExecutionHints(): NadelExecutionHints.Builder { return super.makeExecutionHints() - .virtualTypeSupport { true } .shortCircuitEmptyQuery { true } } diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationScalarFieldTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationScalarFieldTest.kt index e69df66fe..8cb264dab 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationScalarFieldTest.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationScalarFieldTest.kt @@ -67,7 +67,6 @@ class StaticHydrationScalarFieldTest : NadelIntegrationTest( ) { override fun makeExecutionHints(): NadelExecutionHints.Builder { return super.makeExecutionHints() - .virtualTypeSupport { true } .shortCircuitEmptyQuery { true } } } diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationTest.kt index 9462784f6..c0fe194d9 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationTest.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationTest.kt @@ -199,7 +199,6 @@ class StaticHydrationTest : NadelIntegrationTest( ) { override fun makeExecutionHints(): NadelExecutionHints.Builder { return super.makeExecutionHints() - .virtualTypeSupport { true } .shortCircuitEmptyQuery { true } } } diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTest.kt deleted file mode 100644 index 1794e0fd9..000000000 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTest.kt +++ /dev/null @@ -1,202 +0,0 @@ -package graphql.nadel.tests.next.fixtures.hydration.statics - -import graphql.nadel.NadelExecutionHints -import graphql.nadel.engine.util.strictAssociateBy -import graphql.nadel.tests.next.NadelIntegrationTest - -/** - * Tests what happens if the virtual types hint is off. - */ -class StaticHydrationVirtualTypeHintOffTest : NadelIntegrationTest( - query = """ - query { - businessReport_findRecentWorkByTeam(teamId: "hello") { - edges { - node { - ... on JiraIssue { - key - } - } - cursor - } - pageInfo { - hasNextPage - } - } - } - """.trimIndent(), - services = listOf( - // Backing service - Service( - name = "graph_store", - overallSchema = """ - type Query { - graphStore_query( - query: String! - first: Int - after: String - ): GraphStoreQueryConnection - } - type GraphStoreQueryConnection { - edges: [GraphStoreQueryEdge] - pageInfo: PageInfo - } - type GraphStoreQueryEdge { - nodeId: ID - cursor: String - } - type PageInfo { - hasNextPage: Boolean! - hasPreviousPage: Boolean! - startCursor: String - endCursor: String - } - """.trimIndent(), - runtimeWiring = { wiring -> - data class GraphStoreQueryEdge( - val nodeId: String, - val cursor: String?, - ) - - data class PageInfo( - val hasNextPage: Boolean, - val hasPreviousPage: Boolean, - val startCursor: String?, - val endCursor: String?, - ) - - data class GraphStoreQueryConnection( - val edges: List, - val pageInfo: PageInfo, - ) - - wiring - .type("Query") { type -> - type - .dataFetcher("graphStore_query") { env -> - GraphStoreQueryConnection( - edges = listOf( - GraphStoreQueryEdge( - nodeId = "ari:cloud:jira::issue/1", - cursor = "1", - ), - ), - pageInfo = PageInfo( - hasNextPage = true, - hasPreviousPage = false, - startCursor = null, - endCursor = "1", - ), - ) - } - } - }, - ), - // Service for hydration - Service( - name = "jira", - overallSchema = """ - type Query { - issuesByIds(ids: [ID!]!): [JiraIssue] - } - type JiraIssue { - id: ID! - key: String! - title: String! - } - """.trimIndent(), - runtimeWiring = { runtime -> - data class JiraIssue( - val id: String, - val key: String, - val title: String, - ) - - val issuesByIds = listOf( - JiraIssue( - id = "ari:cloud:jira::issue/1", - key = "GQLGW-1", - title = "Fix the speed of light", - ), - JiraIssue( - id = "ari:cloud:jira::issue/2", - key = "GQLGW-2", - title = "Refactor Nadel", - ), - ).strictAssociateBy { it.id } - - runtime - .type("Query") { type -> - type - .dataFetcher("issuesByIds") { env -> - val ids = env.getArgument>("ids") - - ids!! - .map { - issuesByIds[it] - } - } - } - }, - ), - // Service that introduces virtual type - Service( - name = "work", - overallSchema = """ - type Query { - businessReport_findRecentWorkByTeam( - teamId: ID! - first: Int - after: String - ): WorkConnection - @hydrated( - service: "graph_store", - field: "graphStore_query" - arguments: [ - { - name: "query" - value: "SELECT * FROM Work WHERE teamId = ?" - } - { - name: "first" - value: "$argument.first" - } - { - name: "after" - value: "$argument.after" - } - ] - ) - } - type WorkConnection @virtualType { - edges: [WorkEdge] - pageInfo: PageInfo - } - type WorkEdge @virtualType { - nodeId: ID @hidden - node: WorkNode - @hydrated( - service: "jira" - field: "issuesByIds" - arguments: [{name: "ids", value: "$source.nodeId"}] - ) - cursor: String - } - union WorkNode = JiraIssue - """.trimIndent(), - underlyingSchema = """ - type Query { - business_stub: String - } - """.trimIndent(), - runtimeWiring = { wiring -> - }, - ), - ), -) { - override fun makeExecutionHints(): NadelExecutionHints.Builder { - return super.makeExecutionHints() - .virtualTypeSupport { false } - .shortCircuitEmptyQuery { true } - } -} diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTestSnapshot.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTestSnapshot.kt deleted file mode 100644 index 4e209773d..000000000 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTestSnapshot.kt +++ /dev/null @@ -1,70 +0,0 @@ -// @formatter:off -package graphql.nadel.tests.next.fixtures.hydration.statics - -import graphql.nadel.tests.next.ExpectedNadelResult -import graphql.nadel.tests.next.ExpectedServiceCall -import graphql.nadel.tests.next.TestSnapshot -import graphql.nadel.tests.next.listOfJsonStrings -import kotlin.Suppress -import kotlin.collections.List -import kotlin.collections.listOf - -private suspend fun main() { - graphql.nadel.tests.next.update() -} - -/** - * This class is generated. Do NOT modify. - * - * Refer to [graphql.nadel.tests.next.UpdateTestSnapshots - */ -@Suppress("unused") -public class StaticHydrationVirtualTypeHintOffTestSnapshot : TestSnapshot() { - override val calls: List = listOf( - ExpectedServiceCall( - service = "graph_store", - query = """ - | { - | graphStore_query(query: "SELECT * FROM Work WHERE teamId = ?") { - | __typename__type_filter__edges: __typename - | __typename__type_filter__pageInfo: __typename - | } - | } - """.trimMargin(), - variables = " {}", - result = """ - | { - | "data": { - | "graphStore_query": { - | "__typename__type_filter__edges": "GraphStoreQueryConnection", - | "__typename__type_filter__pageInfo": "GraphStoreQueryConnection" - | } - | } - | } - """.trimMargin(), - delayedResults = listOfJsonStrings( - ), - ), - ) - - /** - * ```json - * { - * "data": { - * "businessReport_findRecentWorkByTeam": {} - * } - * } - * ``` - */ - override val result: ExpectedNadelResult = ExpectedNadelResult( - result = """ - | { - | "data": { - | "businessReport_findRecentWorkByTeam": {} - | } - | } - """.trimMargin(), - delayedResults = listOfJsonStrings( - ), - ) -} diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/schema/CustomHydrationDirectiveTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/schema/CustomHydrationDirectiveTest.kt index 5d931064b..21e242f71 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/schema/CustomHydrationDirectiveTest.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/schema/CustomHydrationDirectiveTest.kt @@ -2,7 +2,6 @@ package graphql.nadel.tests.next.fixtures.schema import graphql.language.Value import graphql.nadel.Nadel -import graphql.nadel.NadelExecutionHints import graphql.nadel.definition.NadelInstructionDefinition import graphql.nadel.definition.hydration.NadelBatchObjectIdentifiedByDefinition import graphql.nadel.definition.hydration.NadelHydrationArgumentDefinition @@ -368,9 +367,4 @@ class CustomHydrationDirectiveTest : NadelIntegrationTest( } }.create() } - - override fun makeExecutionHints(): NadelExecutionHints.Builder { - return super.makeExecutionHints() - .virtualTypeSupport { true } - } }