@@ -4,6 +4,7 @@ import graphql.introspection.Introspection
44import graphql.nadel.Service
55import graphql.nadel.ServiceExecutionHydrationDetails
66import graphql.nadel.ServiceExecutionResult
7+ import graphql.nadel.definition.hydration.NadelHydrationConditionDefinition.Keyword.result
78import graphql.nadel.engine.NadelExecutionContext
89import graphql.nadel.engine.NadelServiceExecutionContext
910import graphql.nadel.engine.blueprint.IntrospectionService
@@ -97,33 +98,43 @@ class NadelServiceTypeFilterTransform : NadelTransform<State> {
9798 val underlyingTypeNamesOwnedByService = executionBlueprint.getUnderlyingTypeNamesForService(service)
9899
99100 val shadow = executionContext.hints.shadowUnderlyingTypeNameInvestigation(executionContext)
101+ val useReachableUnderlyingServiceTypes = executionContext.hints.useReachableUnderlyingServiceTypes(service)
102+ val disableSharedTypes = executionContext.hints.disableSharedTypes(service)
100103
101104 fun checkSharedTypes (objectTypeName : String ): Boolean {
102- val result = executionContext.hints.sharedTypeRenames(service)
103- && executionBlueprint.getUnderlyingTypeName(objectTypeName) in underlyingTypeNamesOwnedByService
104- if (result && shadow) {
105- executionContext.hooks.reportSharedTypeDecisionImpact(executionContext, service, objectTypeName)
105+ return if (disableSharedTypes) {
106+ false
107+ } else {
108+ val result = executionContext.hints.sharedTypeRenames(service)
109+ && executionBlueprint.getUnderlyingTypeName(objectTypeName) in underlyingTypeNamesOwnedByService
110+ if (result && shadow) {
111+ executionContext.hooks.reportSharedTypeDecisionImpact(executionContext, service, objectTypeName)
112+ }
113+ result
106114 }
107- return result
108115 }
109116
110117 fun checkUnderlyingType (objectTypeName : String ): Boolean {
111- val result = objectTypeName in underlyingTypeNamesOwnedByService
112- if (shadow) {
113- val reachableUnderlyingTypeNameCheck =
114- objectTypeName in executionBlueprint.getReachableUnderlyingTypeNamesForService(service)
115- val reducedUnderlyingTypeNameCheck =
116- objectTypeName in executionBlueprint.getReducedUnderlyingTypeNamesForService(service)
117- if (result != reachableUnderlyingTypeNameCheck) {
118- executionContext.hooks
119- .reportReachableTypeDecisionInconsistency(executionContext, service, objectTypeName)
120- }
121- if (result != reducedUnderlyingTypeNameCheck) {
122- executionContext.hooks
123- .reportReducedTypeDecisionInconsistency(executionContext, service, objectTypeName)
118+ return if (useReachableUnderlyingServiceTypes) {
119+ objectTypeName in executionBlueprint.getReachableUnderlyingTypeNamesForService(service)
120+ } else {
121+ val result = objectTypeName in underlyingTypeNamesOwnedByService
122+ if (shadow) {
123+ val reachableUnderlyingTypeNameCheck =
124+ objectTypeName in executionBlueprint.getReachableUnderlyingTypeNamesForService(service)
125+ val reducedUnderlyingTypeNameCheck =
126+ objectTypeName in executionBlueprint.getReducedUnderlyingTypeNamesForService(service)
127+ if (result != reachableUnderlyingTypeNameCheck) {
128+ executionContext.hooks
129+ .reportReachableTypeDecisionInconsistency(executionContext, service, objectTypeName)
130+ }
131+ if (result != reducedUnderlyingTypeNameCheck) {
132+ executionContext.hooks
133+ .reportReducedTypeDecisionInconsistency(executionContext, service, objectTypeName)
134+ }
124135 }
136+ result
125137 }
126- return result
127138 }
128139
129140 // Assume for most cases there aren't foreign types so there is no point filtering to a new List
0 commit comments