diff --git a/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt b/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt index 83c89375e..eca2ab29b 100644 --- a/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt +++ b/lib/src/main/java/graphql/nadel/NadelExecutionHints.kt @@ -12,14 +12,12 @@ import graphql.nadel.hints.NadelNoInterfaceToObjectFragmentExpansionHint import graphql.nadel.hints.NadelReachableUnderlyingServiceTypesHint import graphql.nadel.hints.NadelShadowUnderlyingTypeNameInvestigation import graphql.nadel.hints.NadelSharedTypeRenamesHint -import graphql.nadel.hints.NadelVirtualTypeSupportHint data class NadelExecutionHints( val legacyOperationNames: LegacyOperationNamesHint, val allDocumentVariablesHint: AllDocumentVariablesHint, val deferSupport: NadelDeferSupportHint, val sharedTypeRenames: NadelSharedTypeRenamesHint, - val virtualTypeSupport: NadelVirtualTypeSupportHint, val executeOnEngineSchema: NadelExecuteOnEngineSchemaHint, val hydrationFilterObjectTypes: NadelHydrationFilterObjectTypesHint, val hydrationExecutableSourceFields: NadelHydrationExecutableSourceFields, @@ -44,7 +42,6 @@ data class NadelExecutionHints( private var allDocumentVariablesHint = AllDocumentVariablesHint { false } private var deferSupport = NadelDeferSupportHint { 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 } @@ -61,7 +58,6 @@ data class NadelExecutionHints( allDocumentVariablesHint = nadelExecutionHints.allDocumentVariablesHint deferSupport = nadelExecutionHints.deferSupport sharedTypeRenames = nadelExecutionHints.sharedTypeRenames - virtualTypeSupport = nadelExecutionHints.virtualTypeSupport executeOnEngineSchema = nadelExecutionHints.executeOnEngineSchema hydrationFilterObjectTypes = nadelExecutionHints.hydrationFilterObjectTypes hydrationExecutableSourceFields = nadelExecutionHints.hydrationExecutableSourceFields @@ -92,11 +88,6 @@ data class NadelExecutionHints( return this } - fun virtualTypeSupport(flag: NadelVirtualTypeSupportHint): Builder { - virtualTypeSupport = flag - return this - } - fun executeOnEngineSchema(flag: NadelExecuteOnEngineSchemaHint): Builder { executeOnEngineSchema = flag return this @@ -143,7 +134,6 @@ data class NadelExecutionHints( allDocumentVariablesHint, deferSupport, sharedTypeRenames, - 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 eaded5eeb..8144dc91c 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 @@ -1,7 +1,6 @@ package graphql.nadel.tests.next.fixtures.hydration import graphql.nadel.Nadel -import graphql.nadel.NadelExecutionHints import graphql.nadel.engine.util.strictAssociateBy import graphql.nadel.tests.next.NadelIntegrationTest import graphql.scalars.ExtendedScalars @@ -170,9 +169,4 @@ class HydrationRemainingArgumentsTest : NadelIntegrationTest( }, ), ), -) { - override fun makeExecutionHints(): NadelExecutionHints.Builder { - return super.makeExecutionHints() - .virtualTypeSupport { 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 70771a9bd..e6e588361 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 @@ -1,7 +1,6 @@ package graphql.nadel.tests.next.fixtures.hydration.statics import graphql.nadel.Nadel -import graphql.nadel.NadelExecutionHints import graphql.nadel.engine.blueprint.NadelGenericHydrationInstruction import graphql.nadel.engine.transform.artificial.NadelAliasHelper import graphql.nadel.engine.transform.result.json.JsonNode @@ -260,11 +259,6 @@ class StaticHydrationAndPolymorphicHydrationTest : NadelIntegrationTest( ), ), ) { - override fun makeExecutionHints(): NadelExecutionHints.Builder { - return super.makeExecutionHints() - .virtualTypeSupport { true } - } - override fun makeNadel(): Nadel.Builder { return super.makeNadel() .executionHooks( 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 70735be64..16f35860c 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 @@ -1,7 +1,6 @@ package graphql.nadel.tests.next.fixtures.hydration.statics import graphql.nadel.Nadel -import graphql.nadel.NadelExecutionHints import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext @@ -208,11 +207,6 @@ class StaticHydrationNestedErrorTest : NadelIntegrationTest( ), ), ) { - override fun makeExecutionHints(): NadelExecutionHints.Builder { - return super.makeExecutionHints() - .virtualTypeSupport { true } - } - override fun makeNadel(): Nadel.Builder { return super.makeNadel() .transforms( 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 30d0e6c93..4921fcf5b 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 @@ -1,7 +1,6 @@ package graphql.nadel.tests.next.fixtures.hydration.statics import graphql.nadel.Nadel -import graphql.nadel.NadelExecutionHints import graphql.nadel.engine.blueprint.NadelGenericHydrationInstruction import graphql.nadel.engine.transform.artificial.NadelAliasHelper import graphql.nadel.engine.transform.result.json.JsonNode @@ -255,11 +254,6 @@ class StaticHydrationOverlappingHydrationTest : NadelIntegrationTest( ), ), ) { - override fun makeExecutionHints(): NadelExecutionHints.Builder { - return super.makeExecutionHints() - .virtualTypeSupport { true } - } - override fun makeNadel(): Nadel.Builder { return super.makeNadel() .executionHooks( 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 aabab16b0..6b76fa632 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 @@ -1,6 +1,5 @@ package graphql.nadel.tests.next.fixtures.hydration.statics -import graphql.nadel.NadelExecutionHints import graphql.nadel.tests.next.NadelIntegrationTest class StaticHydrationScalarFieldTest : NadelIntegrationTest( @@ -64,9 +63,4 @@ class StaticHydrationScalarFieldTest : NadelIntegrationTest( }, ), ), -) { - override fun makeExecutionHints(): NadelExecutionHints.Builder { - return super.makeExecutionHints() - .virtualTypeSupport { 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 2edf6a206..0e189c1cc 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 @@ -1,6 +1,5 @@ package graphql.nadel.tests.next.fixtures.hydration.statics -import graphql.nadel.NadelExecutionHints import graphql.nadel.engine.util.strictAssociateBy import graphql.nadel.tests.next.NadelIntegrationTest @@ -196,9 +195,4 @@ class StaticHydrationTest : NadelIntegrationTest( }, ), ), -) { - override fun makeExecutionHints(): NadelExecutionHints.Builder { - return super.makeExecutionHints() - .virtualTypeSupport { 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 e4f6f7a01..000000000 --- a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/statics/StaticHydrationVirtualTypeHintOffTest.kt +++ /dev/null @@ -1,201 +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 } - } -} 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 } - } }