diff --git a/lib/src/main/java/graphql/nadel/NextgenEngine.kt b/lib/src/main/java/graphql/nadel/NextgenEngine.kt index 704c44e7c..c5b065b8e 100644 --- a/lib/src/main/java/graphql/nadel/NextgenEngine.kt +++ b/lib/src/main/java/graphql/nadel/NextgenEngine.kt @@ -11,6 +11,7 @@ import graphql.introspection.Introspection.TypeNameMetaFieldDef import graphql.language.Document import graphql.nadel.engine.NadelExecutionContext import graphql.nadel.engine.NadelIncrementalResultSupport +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.IntrospectionService import graphql.nadel.engine.blueprint.NadelDefaultIntrospectionRunner import graphql.nadel.engine.blueprint.NadelExecutionBlueprintFactory @@ -36,6 +37,7 @@ import graphql.nadel.engine.util.provide import graphql.nadel.engine.util.singleOfType import graphql.nadel.engine.util.strictAssociateBy import graphql.nadel.hooks.NadelExecutionHooks +import graphql.nadel.hooks.createServiceExecutionContext import graphql.nadel.instrumentation.NadelInstrumentation import graphql.nadel.instrumentation.parameters.ErrorData import graphql.nadel.instrumentation.parameters.ErrorType.ServiceExecutionError @@ -257,10 +259,13 @@ internal class NextgenEngine( service: Service, executionContext: NadelExecutionContext, ): ServiceExecutionResult { + val serviceExecutionContext = executionHooks.createServiceExecutionContext(service) + val timer = executionContext.timer val executionPlan = timer.time(step = RootStep.ExecutionPlanning) { executionPlanner.create( executionContext = executionContext, + serviceExecutionContext = serviceExecutionContext, services = services, service = service, rootField = topLevelField, @@ -268,7 +273,13 @@ internal class NextgenEngine( ) } val queryTransform = timer.time(step = RootStep.QueryTransforming) { - transformQuery(service, executionContext, executionPlan, topLevelField) + transformQuery( + service = service, + executionContext = executionContext, + serviceExecutionContext = serviceExecutionContext, + executionPlan = executionPlan, + field = topLevelField + ) } val transformedQuery = queryTransform.result.single() val result: ServiceExecutionResult = timer.time(step = RootStep.ServiceExecution.child(service.name)) { @@ -276,6 +287,7 @@ internal class NextgenEngine( service = service, transformedQuery = transformedQuery, executionContext = executionContext, + serviceExecutionContext = serviceExecutionContext, executionHydrationDetails = executionContext.hydrationDetails, ) } @@ -284,6 +296,7 @@ internal class NextgenEngine( else -> timer.time(step = RootStep.ResultTransforming) { resultTransformer.transform( executionContext = executionContext, + serviceExecutionContext = serviceExecutionContext, executionPlan = executionPlan, artificialFields = queryTransform.artificialFields, overallToUnderlyingFields = queryTransform.overallToUnderlyingFields, @@ -300,6 +313,7 @@ internal class NextgenEngine( service: Service, transformedQuery: ExecutableNormalizedField, executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionHydrationDetails: ServiceExecutionHydrationDetails? = null, ): ServiceExecutionResult { val timer = executionContext.timer @@ -327,6 +341,7 @@ internal class NextgenEngine( variables = compileResult.variables, operationDefinition = compileResult.document.definitions.singleOfType(), serviceContext = executionContext.getContextForService(service).await(), + serviceExecutionContext = serviceExecutionContext, hydrationDetails = executionHydrationDetails, executableNormalizedField = transformedQuery, ) @@ -424,6 +439,7 @@ internal class NextgenEngine( private suspend fun transformQuery( service: Service, executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionPlan: NadelExecutionPlan, field: ExecutableNormalizedField, ): NadelQueryTransformer.TransformResult { @@ -431,6 +447,7 @@ internal class NextgenEngine( overallExecutionBlueprint, service, executionContext, + serviceExecutionContext, executionPlan, field, ) diff --git a/lib/src/main/java/graphql/nadel/ServiceExecutionParameters.kt b/lib/src/main/java/graphql/nadel/ServiceExecutionParameters.kt index 45d8b2e93..89c4debe4 100644 --- a/lib/src/main/java/graphql/nadel/ServiceExecutionParameters.kt +++ b/lib/src/main/java/graphql/nadel/ServiceExecutionParameters.kt @@ -4,6 +4,7 @@ import graphql.GraphQLContext import graphql.execution.ExecutionId import graphql.language.Document import graphql.language.OperationDefinition +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.normalized.ExecutableNormalizedField class ServiceExecutionParameters internal constructor( @@ -13,6 +14,7 @@ class ServiceExecutionParameters internal constructor( val variables: Map, val operationDefinition: OperationDefinition, val executionId: ExecutionId, + val serviceExecutionContext: NadelServiceExecutionContext, private val serviceContext: Any?, /** * @return details abut this service hydration or null if it's not a hydration call @@ -20,6 +22,7 @@ class ServiceExecutionParameters internal constructor( val hydrationDetails: ServiceExecutionHydrationDetails?, val executableNormalizedField: ExecutableNormalizedField, ) { + @Deprecated("Use serviceExecutionContext instead") fun getServiceContext(): T? { @Suppress("UNCHECKED_CAST") // Trust caller return serviceContext as T? diff --git a/lib/src/main/java/graphql/nadel/engine/NadelExecutionContext.kt b/lib/src/main/java/graphql/nadel/engine/NadelExecutionContext.kt index 17d5c44cd..5bf946fd9 100644 --- a/lib/src/main/java/graphql/nadel/engine/NadelExecutionContext.kt +++ b/lib/src/main/java/graphql/nadel/engine/NadelExecutionContext.kt @@ -44,6 +44,7 @@ data class NadelExecutionContext internal constructor( /** * Get the service context for a given service */ + @Deprecated("Replaced with NadelServiceExecutionContext") fun getContextForService(service: Service): CompletableFuture { return serviceContexts.getOrPut(service.name) { hooks.createServiceContext( diff --git a/lib/src/main/java/graphql/nadel/engine/NadelServiceExecutionContext.kt b/lib/src/main/java/graphql/nadel/engine/NadelServiceExecutionContext.kt new file mode 100644 index 000000000..8270a4ac3 --- /dev/null +++ b/lib/src/main/java/graphql/nadel/engine/NadelServiceExecutionContext.kt @@ -0,0 +1,12 @@ +package graphql.nadel.engine + +/** + * Base class for context objects created for one service execution. + * + * This is created for each portion of the query we execute. + * + * This is NOT shared with other executions to the same service. + */ +abstract class NadelServiceExecutionContext { + internal object None : NadelServiceExecutionContext() +} diff --git a/lib/src/main/java/graphql/nadel/engine/plan/NadelExecutionPlanFactory.kt b/lib/src/main/java/graphql/nadel/engine/plan/NadelExecutionPlanFactory.kt index 86853563e..d1d27be3f 100644 --- a/lib/src/main/java/graphql/nadel/engine/plan/NadelExecutionPlanFactory.kt +++ b/lib/src/main/java/graphql/nadel/engine/plan/NadelExecutionPlanFactory.kt @@ -4,6 +4,7 @@ import graphql.nadel.NextgenEngine import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelDeepRenameTransform import graphql.nadel.engine.transform.NadelRenameArgumentInputTypesTransform @@ -35,6 +36,7 @@ internal class NadelExecutionPlanFactory( */ suspend fun create( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, services: Map, service: Service, rootField: ExecutableNormalizedField, @@ -55,6 +57,7 @@ internal class NadelExecutionPlanFactory( val state = timer.time(step = timingStep) { transform.isApplicable( executionContext, + serviceExecutionContext, executionBlueprint, services, service, diff --git a/lib/src/main/java/graphql/nadel/engine/transform/NadelDeepRenameTransform.kt b/lib/src/main/java/graphql/nadel/engine/transform/NadelDeepRenameTransform.kt index 9dde4cb02..976c7c573 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/NadelDeepRenameTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/NadelDeepRenameTransform.kt @@ -4,6 +4,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelDeepRenameFieldInstruction import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.blueprint.getTypeNameToInstructionMap @@ -82,6 +83,7 @@ internal class NadelDeepRenameTransform : NadelTransform, service: Service, @@ -153,6 +155,7 @@ internal class NadelDeepRenameTransform : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -47,6 +49,7 @@ internal class NadelRenameArgumentInputTypesTransform : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -63,6 +66,7 @@ internal class NadelRenameArgumentInputTypesTransform : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/lib/src/main/java/graphql/nadel/engine/transform/NadelRenameTransform.kt b/lib/src/main/java/graphql/nadel/engine/transform/NadelRenameTransform.kt index 60a3f9bc9..9fe042882 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/NadelRenameTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/NadelRenameTransform.kt @@ -4,6 +4,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.blueprint.NadelRenameFieldInstruction import graphql.nadel.engine.blueprint.getTypeNameToInstructionMap @@ -38,6 +39,7 @@ internal class NadelRenameTransform : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -66,6 +68,7 @@ internal class NadelRenameTransform : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -173,10 +176,11 @@ internal class NadelRenameTransform : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, - underlyingParentField: ExecutableNormalizedField?, // Overall field + underlyingParentField: ExecutableNormalizedField?, result: ServiceExecutionResult, state: State, nodes: JsonNodes, 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 5a31a785f..48dd57c83 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/NadelServiceTypeFilterTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/NadelServiceTypeFilterTransform.kt @@ -5,6 +5,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.IntrospectionService import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelServiceTypeFilterTransform.State @@ -71,6 +72,7 @@ class NadelServiceTypeFilterTransform : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -120,6 +122,7 @@ class NadelServiceTypeFilterTransform : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -175,6 +178,7 @@ class NadelServiceTypeFilterTransform : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/lib/src/main/java/graphql/nadel/engine/transform/NadelTransform.kt b/lib/src/main/java/graphql/nadel/engine/transform/NadelTransform.kt index d8efaf2f1..210a79229 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/NadelTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/NadelTransform.kt @@ -5,6 +5,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.query.NadelQueryTransformer import graphql.nadel.engine.transform.result.NadelResultInstruction @@ -40,6 +41,7 @@ interface NadelTransform { */ suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -56,6 +58,7 @@ interface NadelTransform { */ suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -71,6 +74,7 @@ interface NadelTransform { */ suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/lib/src/main/java/graphql/nadel/engine/transform/NadelTransformJavaCompat.kt b/lib/src/main/java/graphql/nadel/engine/transform/NadelTransformJavaCompat.kt index d501f57ff..089fea8e0 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/NadelTransformJavaCompat.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/NadelTransformJavaCompat.kt @@ -4,6 +4,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.query.NadelQueryTransformer import graphql.nadel.engine.transform.query.NadelQueryTransformerJavaCompat @@ -26,6 +27,7 @@ interface NadelTransformJavaCompat { */ fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -38,6 +40,7 @@ interface NadelTransformJavaCompat { */ fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformerJavaCompat, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -50,6 +53,7 @@ interface NadelTransformJavaCompat { */ fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, @@ -68,6 +72,7 @@ interface NadelTransformJavaCompat { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -76,6 +81,7 @@ interface NadelTransformJavaCompat { ): State? { return compat.isApplicable( executionContext = executionContext, + serviceExecutionContext = serviceExecutionContext, executionBlueprint = executionBlueprint, services = services, service = service, @@ -86,6 +92,7 @@ interface NadelTransformJavaCompat { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -97,6 +104,7 @@ interface NadelTransformJavaCompat { compat.transformField( executionContext = executionContext, + serviceExecutionContext = serviceExecutionContext, transformer = NadelQueryTransformerJavaCompat(transformer, scope), executionBlueprint = executionBlueprint, service = service, @@ -108,6 +116,7 @@ interface NadelTransformJavaCompat { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, @@ -119,6 +128,7 @@ interface NadelTransformJavaCompat { return compat.getResultInstructions( executionContext = executionContext, executionBlueprint = executionBlueprint, + serviceExecutionContext = serviceExecutionContext, service = service, overallField = overallField, underlyingParentField = underlyingParentField, 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 7446cd4d8..beca210db 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/NadelTypeRenameResultTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/NadelTypeRenameResultTransform.kt @@ -5,6 +5,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTypeRenameResultTransform.State import graphql.nadel.engine.transform.query.NadelQueryPath @@ -24,6 +25,7 @@ internal class NadelTypeRenameResultTransform : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -41,6 +43,7 @@ internal class NadelTypeRenameResultTransform : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -52,6 +55,7 @@ internal class NadelTypeRenameResultTransform : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, 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 c2bf39a29..b804b4b61 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 @@ -7,6 +7,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelGenericHydrationInstruction import graphql.nadel.engine.blueprint.NadelHydrationFieldInstruction import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint @@ -69,6 +70,7 @@ internal class NadelHydrationTransform( override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -93,6 +95,7 @@ internal class NadelHydrationTransform( override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -147,6 +150,7 @@ internal class NadelHydrationTransform( override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/lib/src/main/java/graphql/nadel/engine/transform/hydration/batch/NadelBatchHydrationTransform.kt b/lib/src/main/java/graphql/nadel/engine/transform/hydration/batch/NadelBatchHydrationTransform.kt index 99505388d..ac2340dbe 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/hydration/batch/NadelBatchHydrationTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/hydration/batch/NadelBatchHydrationTransform.kt @@ -5,6 +5,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelBatchHydrationFieldInstruction import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.blueprint.getTypeNameToInstructionsMap @@ -40,6 +41,7 @@ internal class NadelBatchHydrationTransform( override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -65,6 +67,7 @@ internal class NadelBatchHydrationTransform( override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -103,6 +106,7 @@ internal class NadelBatchHydrationTransform( override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, 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 422ea22b6..32b714c9e 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 @@ -2,6 +2,7 @@ package graphql.nadel.engine.transform.query import graphql.nadel.Service import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.plan.NadelExecutionPlan import graphql.nadel.engine.transform.NadelTransform @@ -13,6 +14,7 @@ class NadelQueryTransformer private constructor( private val executionBlueprint: NadelOverallExecutionBlueprint, private val service: Service, private val executionContext: NadelExecutionContext, + private val serviceExecutionContext: NadelServiceExecutionContext, private val executionPlan: NadelExecutionPlan, private val transformContext: TransformContext, ) { @@ -21,6 +23,7 @@ class NadelQueryTransformer private constructor( executionBlueprint: NadelOverallExecutionBlueprint, service: Service, executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionPlan: NadelExecutionPlan, field: ExecutableNormalizedField, ): TransformResult { @@ -30,6 +33,7 @@ class NadelQueryTransformer private constructor( executionBlueprint, service, executionContext, + serviceExecutionContext, executionPlan, transformContext, ) @@ -148,6 +152,7 @@ class NadelQueryTransformer private constructor( for ((_, _, transform, state) in transformationSteps) { val transformResultForStep = transform.transformField( executionContext, + serviceExecutionContext, this, executionBlueprint, service, diff --git a/lib/src/main/java/graphql/nadel/engine/transform/result/NadelResultTransformer.kt b/lib/src/main/java/graphql/nadel/engine/transform/result/NadelResultTransformer.kt index 9a94c6de1..1fa73da9e 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/result/NadelResultTransformer.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/result/NadelResultTransformer.kt @@ -3,6 +3,7 @@ package graphql.nadel.engine.transform.result import graphql.nadel.Service import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.plan.NadelExecutionPlan import graphql.nadel.engine.transform.result.json.JsonNodes @@ -18,6 +19,7 @@ import kotlinx.coroutines.coroutineScope internal class NadelResultTransformer(private val executionBlueprint: NadelOverallExecutionBlueprint) { suspend fun transform( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionPlan: NadelExecutionPlan, artificialFields: List, overallToUnderlyingFields: Map>, @@ -41,6 +43,7 @@ internal class NadelResultTransformer(private val executionBlueprint: NadelOvera async { step.transform.getResultInstructions( executionContext, + serviceExecutionContext, executionBlueprint, service, field, diff --git a/lib/src/main/java/graphql/nadel/engine/transform/skipInclude/NadelSkipIncludeTransform.kt b/lib/src/main/java/graphql/nadel/engine/transform/skipInclude/NadelSkipIncludeTransform.kt index 215e9535f..14b45775a 100644 --- a/lib/src/main/java/graphql/nadel/engine/transform/skipInclude/NadelSkipIncludeTransform.kt +++ b/lib/src/main/java/graphql/nadel/engine/transform/skipInclude/NadelSkipIncludeTransform.kt @@ -7,6 +7,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -59,6 +60,7 @@ internal class NadelSkipIncludeTransform : NadelTransform { */ override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -88,6 +90,7 @@ internal class NadelSkipIncludeTransform : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -107,6 +110,7 @@ internal class NadelSkipIncludeTransform : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/lib/src/main/java/graphql/nadel/hooks/NadelCreateServiceExecutionContextParams.kt b/lib/src/main/java/graphql/nadel/hooks/NadelCreateServiceExecutionContextParams.kt new file mode 100644 index 000000000..2b6574b40 --- /dev/null +++ b/lib/src/main/java/graphql/nadel/hooks/NadelCreateServiceExecutionContextParams.kt @@ -0,0 +1,5 @@ +package graphql.nadel.hooks + +import graphql.nadel.Service + +data class NadelCreateServiceExecutionContextParams internal constructor(val service: Service) diff --git a/lib/src/main/java/graphql/nadel/hooks/NadelExecutionHooks.kt b/lib/src/main/java/graphql/nadel/hooks/NadelExecutionHooks.kt index 92e794fbb..92ea113de 100644 --- a/lib/src/main/java/graphql/nadel/hooks/NadelExecutionHooks.kt +++ b/lib/src/main/java/graphql/nadel/hooks/NadelExecutionHooks.kt @@ -1,11 +1,13 @@ package graphql.nadel.hooks import graphql.nadel.Service +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelBatchHydrationFieldInstruction import graphql.nadel.engine.blueprint.NadelGenericHydrationInstruction import graphql.nadel.engine.transform.artificial.NadelAliasHelper import graphql.nadel.engine.transform.result.json.JsonNode import graphql.normalized.ExecutableNormalizedField +import kotlinx.coroutines.future.await import java.util.concurrent.CompletableFuture /** @@ -13,15 +15,24 @@ import java.util.concurrent.CompletableFuture */ interface NadelExecutionHooks { /** - * Called per top level field for a service. This allows you to create a "context" object that will be passed into further calls. + * Creates one context per [Service] per request. + * + * So even if a request has multiple calls to one [Service] we will reuse the same context. + * + * This is deprecated now, please use [createServiceExecutionContext] instead. * * @param params the parameters to this call * @return an async context object of your choosing */ + @Deprecated("Use createServiceExecutionContext instead") fun createServiceContext(params: CreateServiceContextParams): CompletableFuture { return CompletableFuture.completedFuture(null) } + fun createServiceExecutionContext(params: NadelCreateServiceExecutionContextParams): CompletableFuture { + return CompletableFuture.completedFuture(NadelServiceExecutionContext.None) + } + /** * Called to resolve the service that should be used to fetch data for a field that uses dynamic service resolution. * @@ -92,3 +103,14 @@ interface NadelExecutionHooks { return listOf(argumentValues) } } + +/** + * Util function for internal use. + */ +internal suspend fun NadelExecutionHooks.createServiceExecutionContext(service: Service): NadelServiceExecutionContext { + return createServiceExecutionContext( + NadelCreateServiceExecutionContextParams( + service = service, + ), + ).await() +} diff --git a/lib/src/test/kotlin/graphql/nadel/test/NadelTransformAdapter.kt b/lib/src/test/kotlin/graphql/nadel/test/NadelTransformAdapter.kt index adb74738e..7b09167f5 100644 --- a/lib/src/test/kotlin/graphql/nadel/test/NadelTransformAdapter.kt +++ b/lib/src/test/kotlin/graphql/nadel/test/NadelTransformAdapter.kt @@ -4,6 +4,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -15,6 +16,7 @@ import graphql.normalized.ExecutableNormalizedField interface NadelTransformAdapter : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -26,6 +28,7 @@ interface NadelTransformAdapter : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -37,6 +40,7 @@ interface NadelTransformAdapter : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/lib/src/test/kotlin/graphql/nadel/test/NadelTransformJavaCompatAdapter.kt b/lib/src/test/kotlin/graphql/nadel/test/NadelTransformJavaCompatAdapter.kt index 945e910cd..86a255368 100644 --- a/lib/src/test/kotlin/graphql/nadel/test/NadelTransformJavaCompatAdapter.kt +++ b/lib/src/test/kotlin/graphql/nadel/test/NadelTransformJavaCompatAdapter.kt @@ -4,6 +4,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransformFieldResult import graphql.nadel.engine.transform.NadelTransformJavaCompat @@ -16,6 +17,7 @@ import java.util.concurrent.CompletableFuture interface NadelTransformJavaCompatAdapter : NadelTransformJavaCompat { override fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -27,6 +29,7 @@ interface NadelTransformJavaCompatAdapter : NadelTransformJavaCompat { override fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformerJavaCompat, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -38,6 +41,7 @@ interface NadelTransformJavaCompatAdapter : NadelTransformJavaCompat { override fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/lib/src/test/kotlin/graphql/nadel/transform/NadelTransformJavaCompatTest.kt b/lib/src/test/kotlin/graphql/nadel/transform/NadelTransformJavaCompatTest.kt index 114a78179..7a9d7ad46 100644 --- a/lib/src/test/kotlin/graphql/nadel/transform/NadelTransformJavaCompatTest.kt +++ b/lib/src/test/kotlin/graphql/nadel/transform/NadelTransformJavaCompatTest.kt @@ -4,6 +4,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransformFieldResult import graphql.nadel.engine.transform.NadelTransformJavaCompat @@ -51,6 +52,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ override fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -64,6 +66,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ val transformer = NadelTransformJavaCompat.create(compat) val executionContext = mock() + val serviceExecutionContext = mock() val executionBlueprint = mock() val services = mock>() val service = mock() @@ -73,6 +76,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ // when val isApplicable = transformer.isApplicable( executionContext, + serviceExecutionContext, executionBlueprint, services, service, @@ -86,6 +90,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ verify(exactly = 1) { compat.isApplicable( executionContext, + serviceExecutionContext, executionBlueprint, services, service, @@ -106,6 +111,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ override fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformerJavaCompat, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -119,6 +125,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ val transformer = NadelTransformJavaCompat.create(compat) val executionContext = mock() + val serviceExecutionContext = mock() val queryTransformer = mock() val executionBlueprint = mock() val service = mock() @@ -128,6 +135,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ // when val transformField = transformer.transformField( executionContext, + serviceExecutionContext, queryTransformer, executionBlueprint, service, @@ -141,6 +149,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ verify(exactly = 1) { compat.transformField( executionContext, + serviceExecutionContext, // This is another wrapper for Java compat match { it.queryTransformer == queryTransformer }, executionBlueprint, @@ -168,6 +177,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ override fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, @@ -183,6 +193,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ val transformer = NadelTransformJavaCompat.create(compat) val executionContext = mock() + val serviceExecutionContext = mock() val executionBlueprint = mock() val service = mock() val overallField = mock() @@ -194,6 +205,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ // when val getResultInstructions = transformer.getResultInstructions( executionContext, + serviceExecutionContext, executionBlueprint, service, overallField, @@ -209,6 +221,7 @@ class NadelTransformJavaCompatTest : DescribeSpec({ verify(exactly = 1) { compat.getResultInstructions( executionContext, + serviceExecutionContext, executionBlueprint, service, overallField, diff --git a/test/src/test/java/graphql/nadel/tests/hooks/JavaAriTransform.java b/test/src/test/java/graphql/nadel/tests/hooks/JavaAriTransform.java index 286234256..7054ab850 100644 --- a/test/src/test/java/graphql/nadel/tests/hooks/JavaAriTransform.java +++ b/test/src/test/java/graphql/nadel/tests/hooks/JavaAriTransform.java @@ -5,6 +5,7 @@ import graphql.nadel.ServiceExecutionHydrationDetails; import graphql.nadel.ServiceExecutionResult; import graphql.nadel.engine.NadelExecutionContext; +import graphql.nadel.engine.NadelServiceExecutionContext; import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint; import graphql.nadel.engine.transform.NadelTransform; import graphql.nadel.engine.transform.NadelTransformFieldResult; @@ -48,6 +49,7 @@ public String getSingleObjectTypeName(ExecutableNormalizedField overallField) { @NotNull @Override public CompletableFuture> isApplicable(@NotNull NadelExecutionContext executionContext, + @NotNull NadelServiceExecutionContext serviceExecutionContext, @NotNull NadelOverallExecutionBlueprint executionBlueprint, @NotNull Map services, @NotNull Service service, @@ -78,6 +80,7 @@ public CompletableFuture> isApplicable(@NotNull NadelExecutionContex @NotNull @Override public CompletableFuture transformField(@NotNull NadelExecutionContext executionContext, + @NotNull NadelServiceExecutionContext serviceExecutionContext, @NotNull NadelQueryTransformerJavaCompat transformer, @NotNull NadelOverallExecutionBlueprint executionBlueprint, @NotNull Service service, @@ -124,6 +127,7 @@ public CompletableFuture transformField(@NotNull Nade @NotNull @Override public CompletableFuture> getResultInstructions(@NotNull NadelExecutionContext executionContext, + @NotNull NadelServiceExecutionContext serviceExecutionContext, @NotNull NadelOverallExecutionBlueprint executionBlueprint, @NotNull Service service, @NotNull ExecutableNormalizedField overallField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/all-hydration-fields-are-seen-by-transformer.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/all-hydration-fields-are-seen-by-transformer.kt index 4b55e2fab..6fb07474e 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/all-hydration-fields-are-seen-by-transformer.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/all-hydration-fields-are-seen-by-transformer.kt @@ -1,11 +1,11 @@ package graphql.nadel.tests.hooks import graphql.ExecutionResult -import graphql.nadel.NadelExecutionHints import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -28,6 +28,7 @@ class `all-hydration-fields-are-seen-by-transformer` : EngineTestHook { object : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -40,6 +41,7 @@ class `all-hydration-fields-are-seen-by-transformer` : EngineTestHook { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -52,6 +54,7 @@ class `all-hydration-fields-are-seen-by-transformer` : EngineTestHook { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/ari-argument-in-renamed-object-input-in-hydration.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/ari-argument-in-renamed-object-input-in-hydration.kt index 8f0ad75aa..594c1a2fd 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/ari-argument-in-renamed-object-input-in-hydration.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/ari-argument-in-renamed-object-input-in-hydration.kt @@ -10,6 +10,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -37,6 +38,7 @@ class `ari-argument-in-renamed-object-input-in-hydration` : EngineTestHook { object : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -53,6 +55,7 @@ class `ari-argument-in-renamed-object-input-in-hydration` : EngineTestHook { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -97,6 +100,7 @@ class `ari-argument-in-renamed-object-input-in-hydration` : EngineTestHook { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, @@ -112,6 +116,7 @@ class `ari-argument-in-renamed-object-input-in-hydration` : EngineTestHook { object : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -126,6 +131,7 @@ class `ari-argument-in-renamed-object-input-in-hydration` : EngineTestHook { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -137,6 +143,7 @@ class `ari-argument-in-renamed-object-input-in-hydration` : EngineTestHook { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/ari-transforms.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/ari-transforms.kt index 153282cb1..4086b2a3e 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/ari-transforms.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/ari-transforms.kt @@ -5,6 +5,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -24,6 +25,7 @@ import graphql.normalized.NormalizedInputValue private class AriTestTransform : NadelTransform> { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -49,6 +51,7 @@ private class AriTestTransform : NadelTransform> { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -83,6 +86,7 @@ private class AriTestTransform : NadelTransform> { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/chain-input-rename-with-argument-transform.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/chain-input-rename-with-argument-transform.kt index 7595f6dfe..295bff2b0 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/chain-input-rename-with-argument-transform.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/chain-input-rename-with-argument-transform.kt @@ -7,6 +7,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -27,6 +28,7 @@ class `ari-argument-in-renamed-input` : EngineTestHook { object : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -42,6 +44,7 @@ class `ari-argument-in-renamed-input` : EngineTestHook { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -77,6 +80,7 @@ class `ari-argument-in-renamed-input` : EngineTestHook { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/chain-rename-transform.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/chain-rename-transform.kt index a4ecb12d1..87f2ed1e1 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/chain-rename-transform.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/chain-rename-transform.kt @@ -6,6 +6,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -21,6 +22,7 @@ import graphql.normalized.NormalizedInputValue private class ChainRenameTransform : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -32,6 +34,7 @@ private class ChainRenameTransform : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -63,6 +66,7 @@ private class ChainRenameTransform : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/monitor-emits-timings.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/monitor-emits-timings.kt index 7cb5a832e..307ffcf00 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/monitor-emits-timings.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/monitor-emits-timings.kt @@ -6,6 +6,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -31,6 +32,7 @@ import java.util.concurrent.CompletableFuture private class MonitorEmitsTimingsTransform : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -43,6 +45,7 @@ private class MonitorEmitsTimingsTransform : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -55,6 +58,7 @@ private class MonitorEmitsTimingsTransform : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, @@ -71,6 +75,7 @@ private class MonitorEmitsTimingsTransform : NadelTransform { private class JavaTimingTransform : NadelTransformJavaCompat { override fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -82,6 +87,7 @@ private class JavaTimingTransform : NadelTransformJavaCompat { override fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformerJavaCompat, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -93,6 +99,7 @@ private class JavaTimingTransform : NadelTransformJavaCompat { override fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/skip-include-does-not-affect-other-transforms.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/skip-include-does-not-affect-other-transforms.kt index e39467daa..bf510667a 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/skip-include-does-not-affect-other-transforms.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/skip-include-does-not-affect-other-transforms.kt @@ -4,13 +4,13 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult import graphql.nadel.engine.transform.query.NadelQueryTransformer import graphql.nadel.engine.transform.result.NadelResultInstruction import graphql.nadel.engine.transform.result.json.JsonNodes -import graphql.nadel.engine.util.getField import graphql.nadel.tests.EngineTestHook import graphql.nadel.tests.UseHook import graphql.normalized.ExecutableNormalizedField @@ -22,6 +22,7 @@ class `skip-include-does-not-affect-other-transforms` : EngineTestHook { object : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -37,6 +38,7 @@ class `skip-include-does-not-affect-other-transforms` : EngineTestHook { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -50,6 +52,7 @@ class `skip-include-does-not-affect-other-transforms` : EngineTestHook { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/transformer-on-hydration-fields.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/transformer-on-hydration-fields.kt index 15c4c2af4..a244c5adf 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/transformer-on-hydration-fields.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/transformer-on-hydration-fields.kt @@ -5,6 +5,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -38,6 +39,7 @@ class `transformer-on-hydration-fields` : EngineTestHook { object : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -58,6 +60,7 @@ class `transformer-on-hydration-fields` : EngineTestHook { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -80,6 +83,7 @@ class `transformer-on-hydration-fields` : EngineTestHook { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/execution/ServiceExecutionContextTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/execution/ServiceExecutionContextTest.kt new file mode 100644 index 000000000..6a64c2050 --- /dev/null +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/execution/ServiceExecutionContextTest.kt @@ -0,0 +1,233 @@ +package graphql.nadel.tests.next.fixtures.execution + +import graphql.ExecutionResult +import graphql.incremental.DelayedIncrementalPartialResult +import graphql.nadel.Nadel +import graphql.nadel.ServiceExecution +import graphql.nadel.ServiceExecutionHydrationDetails +import graphql.nadel.ServiceExecutionResult +import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext +import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint +import graphql.nadel.engine.transform.NadelTransform +import graphql.nadel.engine.transform.NadelTransformFieldResult +import graphql.nadel.engine.transform.query.NadelQueryTransformer +import graphql.nadel.engine.transform.result.NadelResultInstruction +import graphql.nadel.engine.transform.result.json.JsonNodes +import graphql.nadel.engine.util.strictAssociateBy +import graphql.nadel.hooks.NadelCreateServiceExecutionContextParams +import graphql.nadel.hooks.NadelExecutionHooks +import graphql.nadel.tests.next.NadelIntegrationTest +import graphql.normalized.ExecutableNormalizedField +import java.util.Collections +import java.util.concurrent.CompletableFuture +import kotlin.test.assertTrue + +class ServiceExecutionContextTest : NadelIntegrationTest( + query = """ + query { + bug: issue(id: 6) { + title + } + me { + lastWorkedOn { + title + } + } + } + """.trimIndent(), + services = listOf( + Service( + name = "monolith", + overallSchema = """ + type Query { + me: User + issue(id: ID!): Issue + } + type User { + id: ID! + lastWorkedOnId: ID! @hidden + lastWorkedOn: Issue + @hydrated( + service: "monolith" + field: "issue" + arguments: [ + {name: "id", value: "$source.lastWorkedOnId"} + ] + ) + } + type Issue { + id: ID! + title: String! + } + """.trimIndent(), + runtimeWiring = { wiring -> + data class User( + val id: String, + val lastWorkedOnId: String, + ) + + data class Issue( + val id: String, + val title: String, + ) + + val issuesById = listOf( + Issue(id = "6", title = "Fix cloud ID header not set"), + Issue(id = "9", title = "Improve cloud ID extraction"), + ).strictAssociateBy { it.id } + + val me = User( + id = "1", + lastWorkedOnId = "9", + ) + + wiring + .type("Query") { type -> + type + .dataFetcher("me") { env -> + me + } + .dataFetcher("issue") { env -> + issuesById[env.getArgument("id")] + } + } + }, + ) + ), +) { + private val serviceExecutionContexts = Collections.synchronizedList(mutableListOf()) + + private class ServiceExecutionContext : NadelServiceExecutionContext() { + val isApplicable = Collections.synchronizedList(mutableListOf()) + val transformField = Collections.synchronizedList(mutableListOf()) + val getResultInstructions = Collections.synchronizedList(mutableListOf()) + + override fun toString(): String { + return "ServiceExecutionContext(isApplicable=$isApplicable, transformField=$transformField, getResultInstructions=$getResultInstructions)" + } + } + + fun ExecutableNormalizedField.toExecutionString(): String { + val objects = objectTypeNames.joinToString(separator = ",", prefix = "[", postfix = "]") + val args = normalizedArguments.entries.joinToString( + separator = ",", + prefix = "(", + postfix = ")", + ) { (argName, argValue) -> + "$argName = $argValue" + } + var str = "$objects.$fieldName$args" + if (alias != null) { + str = "$alias: $str" + } + return str + } + + override fun makeNadel(): Nadel.Builder { + return super.makeNadel() + .executionHooks( + object : NadelExecutionHooks { + override fun createServiceExecutionContext( + params: NadelCreateServiceExecutionContextParams, + ): CompletableFuture { + return CompletableFuture.completedFuture(ServiceExecutionContext()) + } + }, + ) + .transforms( + listOf( + object : NadelTransform { + override suspend fun isApplicable( + executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, + executionBlueprint: NadelOverallExecutionBlueprint, + services: Map, + service: graphql.nadel.Service, + overallField: ExecutableNormalizedField, + hydrationDetails: ServiceExecutionHydrationDetails?, + ): Unit? { + (serviceExecutionContext as ServiceExecutionContext).isApplicable.add(overallField.toExecutionString()) + return Unit + } + + override suspend fun transformField( + executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, + transformer: NadelQueryTransformer, + executionBlueprint: NadelOverallExecutionBlueprint, + service: graphql.nadel.Service, + field: ExecutableNormalizedField, + state: Unit, + ): NadelTransformFieldResult { + (serviceExecutionContext as ServiceExecutionContext).transformField.add(field.toExecutionString()) + return NadelTransformFieldResult.unmodified(field) + } + + override suspend fun getResultInstructions( + executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, + executionBlueprint: NadelOverallExecutionBlueprint, + service: graphql.nadel.Service, + overallField: ExecutableNormalizedField, + underlyingParentField: ExecutableNormalizedField?, + result: ServiceExecutionResult, + state: Unit, + nodes: JsonNodes, + ): List { + (serviceExecutionContext as ServiceExecutionContext).getResultInstructions.add(overallField.toExecutionString()) + return emptyList() + } + } + ) + ) + } + + override fun makeServiceExecution(service: Service): ServiceExecution { + val impl = super.makeServiceExecution(service) + + return ServiceExecution { + serviceExecutionContexts.add(it.serviceExecutionContext as ServiceExecutionContext) + impl.execute(it) + } + } + + override fun assert(result: ExecutionResult, incrementalResults: List?) { + // Three separate executions, two for top level fields, and one for hydration + assertTrue(serviceExecutionContexts.size == 3) + + val me = serviceExecutionContexts.single { + it.isApplicable.first().contains("me()") + } + val expectedMeExecutions = listOf( + "[Query].me()", + "[User].lastWorkedOn()", + "[Issue].title()", + ) + assertTrue(me.isApplicable == expectedMeExecutions) + assertTrue(me.transformField == expectedMeExecutions.dropLast(1)) // dropLast as child is removed due to hydration + assertTrue(me.getResultInstructions == expectedMeExecutions.dropLast(1)) + + val bug = serviceExecutionContexts.single { + it.isApplicable.first().contains("bug") + } + val expectedBugExecutions = listOf( + "bug: [Query].issue(id = NormalizedInputValue{typeName='ID!', value=IntValue{value=6}})", + "[Issue].title()", + ) + assertTrue(bug.isApplicable == expectedBugExecutions) + assertTrue(bug.transformField == expectedBugExecutions) + assertTrue(bug.getResultInstructions == expectedBugExecutions) + + val hydration = serviceExecutionContexts.single { + it.isApplicable.first().contains("9") + } + val expectedHydrationExecutions = listOf( + "[Query].issue(id = NormalizedInputValue{typeName='ID!', value=StringValue{value='9'}})", + "[Issue].title()", + ) + assertTrue(hydration.isApplicable == expectedHydrationExecutions) + assertTrue(hydration.transformField == expectedHydrationExecutions) + assertTrue(hydration.getResultInstructions == expectedHydrationExecutions) + } +} diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/execution/ServiceExecutionContextTestSnapshot.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/execution/ServiceExecutionContextTestSnapshot.kt new file mode 100644 index 000000000..eab71c1fe --- /dev/null +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/execution/ServiceExecutionContextTestSnapshot.kt @@ -0,0 +1,128 @@ +// @formatter:off +package graphql.nadel.tests.next.fixtures.execution + +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 ServiceExecutionContextTestSnapshot : TestSnapshot() { + override val calls: List = listOf( + ExpectedServiceCall( + service = "monolith", + query = """ + | { + | bug: issue(id: 6) { + | title + | } + | } + """.trimMargin(), + variables = "{}", + result = """ + | { + | "data": { + | "bug": { + | "title": "Fix cloud ID header not set" + | } + | } + | } + """.trimMargin(), + delayedResults = listOfJsonStrings( + ), + ), + ExpectedServiceCall( + service = "monolith", + query = """ + | { + | issue(id: "9") { + | title + | } + | } + """.trimMargin(), + variables = "{}", + result = """ + | { + | "data": { + | "issue": { + | "title": "Improve cloud ID extraction" + | } + | } + | } + """.trimMargin(), + delayedResults = listOfJsonStrings( + ), + ), + ExpectedServiceCall( + service = "monolith", + query = """ + | { + | me { + | hydration__lastWorkedOn__lastWorkedOnId: lastWorkedOnId + | __typename__hydration__lastWorkedOn: __typename + | } + | } + """.trimMargin(), + variables = "{}", + result = """ + | { + | "data": { + | "me": { + | "hydration__lastWorkedOn__lastWorkedOnId": "9", + | "__typename__hydration__lastWorkedOn": "User" + | } + | } + | } + """.trimMargin(), + delayedResults = listOfJsonStrings( + ), + ), + ) + + /** + * ```json + * { + * "data": { + * "bug": { + * "title": "Fix cloud ID header not set" + * }, + * "me": { + * "lastWorkedOn": { + * "title": "Improve cloud ID extraction" + * } + * } + * } + * } + * ``` + */ + override val result: ExpectedNadelResult = ExpectedNadelResult( + result = """ + | { + | "data": { + | "bug": { + | "title": "Fix cloud ID header not set" + | }, + | "me": { + | "lastWorkedOn": { + | "title": "Improve cloud ID extraction" + | } + | } + | } + | } + """.trimMargin(), + delayedResults = listOfJsonStrings( + ), + ) +} diff --git a/test/src/test/kotlin/graphql/nadel/tests/transforms/RemoveFieldTestTransform.kt b/test/src/test/kotlin/graphql/nadel/tests/transforms/RemoveFieldTestTransform.kt index dbcc8ff12..36a3f32d8 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/transforms/RemoveFieldTestTransform.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/transforms/RemoveFieldTestTransform.kt @@ -6,6 +6,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -23,6 +24,7 @@ import graphql.validation.ValidationErrorType class RemoveFieldTestTransform : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -46,6 +48,7 @@ class RemoveFieldTestTransform : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -68,6 +71,7 @@ class RemoveFieldTestTransform : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField, diff --git a/test/src/test/kotlin/graphql/nadel/tests/util/NadelTransformAdapter.kt b/test/src/test/kotlin/graphql/nadel/tests/util/NadelTransformAdapter.kt index ebb742b2e..054a1cd37 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/util/NadelTransformAdapter.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/util/NadelTransformAdapter.kt @@ -4,6 +4,7 @@ import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.ServiceExecutionResult import graphql.nadel.engine.NadelExecutionContext +import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.NadelTransformFieldResult @@ -15,6 +16,7 @@ import graphql.normalized.ExecutableNormalizedField interface NadelTransformAdapter : NadelTransform { override suspend fun isApplicable( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, services: Map, service: Service, @@ -26,6 +28,7 @@ interface NadelTransformAdapter : NadelTransform { override suspend fun transformField( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, transformer: NadelQueryTransformer, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, @@ -37,6 +40,7 @@ interface NadelTransformAdapter : NadelTransform { override suspend fun getResultInstructions( executionContext: NadelExecutionContext, + serviceExecutionContext: NadelServiceExecutionContext, executionBlueprint: NadelOverallExecutionBlueprint, service: Service, overallField: ExecutableNormalizedField,