diff --git a/lib/src/main/java/graphql/nadel/NextgenEngine.kt b/lib/src/main/java/graphql/nadel/NextgenEngine.kt index 840b7d3e0..c6ad04dd7 100644 --- a/lib/src/main/java/graphql/nadel/NextgenEngine.kt +++ b/lib/src/main/java/graphql/nadel/NextgenEngine.kt @@ -411,7 +411,6 @@ internal class NextgenEngine( executionId = executionInput.executionId ?: executionIdProvider.provide(executionInput), variables = compileResult.variables, operationDefinition = compileResult.document.definitions.singleOfType(), - serviceContext = executionContext.getContextForService(service).await(), serviceExecutionContext = serviceExecutionContext, hydrationDetails = executionHydrationDetails, // Prefer non __typename field first, otherwise we just get first diff --git a/lib/src/main/java/graphql/nadel/ServiceExecutionParameters.kt b/lib/src/main/java/graphql/nadel/ServiceExecutionParameters.kt index 89c4debe4..6891e1346 100644 --- a/lib/src/main/java/graphql/nadel/ServiceExecutionParameters.kt +++ b/lib/src/main/java/graphql/nadel/ServiceExecutionParameters.kt @@ -15,19 +15,12 @@ class ServiceExecutionParameters internal constructor( 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 */ val hydrationDetails: ServiceExecutionHydrationDetails?, val executableNormalizedField: ExecutableNormalizedField, ) { - @Deprecated("Use serviceExecutionContext instead") - fun getServiceContext(): T? { - @Suppress("UNCHECKED_CAST") // Trust caller - return serviceContext as T? - } - val isHydrationCall: Boolean get() = hydrationDetails != null } diff --git a/lib/src/main/java/graphql/nadel/engine/NadelExecutionContext.kt b/lib/src/main/java/graphql/nadel/engine/NadelExecutionContext.kt index ae54cb781..ac41cd2f4 100644 --- a/lib/src/main/java/graphql/nadel/engine/NadelExecutionContext.kt +++ b/lib/src/main/java/graphql/nadel/engine/NadelExecutionContext.kt @@ -4,10 +4,8 @@ import graphql.ExecutionInput import graphql.GraphQLContext import graphql.execution.instrumentation.InstrumentationState import graphql.nadel.NadelExecutionHints -import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.engine.instrumentation.NadelInstrumentationTimer -import graphql.nadel.hooks.CreateServiceContextParams import graphql.nadel.hooks.NadelExecutionHooks import graphql.nadel.result.NadelResultTracker import graphql.normalized.ExecutableNormalizedOperation @@ -43,16 +41,4 @@ data class NadelExecutionContext internal constructor( get() { return executionInput.graphQLContext!! } - - /** - * Get the service context for a given service - */ - @Deprecated("Replaced with NadelServiceExecutionContext") - fun getContextForService(service: Service): CompletableFuture { - return serviceContexts.getOrPut(service.name) { - hooks.createServiceContext( - CreateServiceContextParams(service) - ) - } - } } diff --git a/lib/src/main/java/graphql/nadel/hooks/CreateServiceContextParams.kt b/lib/src/main/java/graphql/nadel/hooks/CreateServiceContextParams.kt deleted file mode 100644 index 7416f317f..000000000 --- a/lib/src/main/java/graphql/nadel/hooks/CreateServiceContextParams.kt +++ /dev/null @@ -1,5 +0,0 @@ -package graphql.nadel.hooks - -import graphql.nadel.Service - -data class CreateServiceContextParams 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 2f2470fe5..b9f8f486f 100644 --- a/lib/src/main/java/graphql/nadel/hooks/NadelExecutionHooks.kt +++ b/lib/src/main/java/graphql/nadel/hooks/NadelExecutionHooks.kt @@ -1,6 +1,5 @@ package graphql.nadel.hooks -import graphql.language.ScalarValue import graphql.nadel.Service import graphql.nadel.ServiceExecutionHydrationDetails import graphql.nadel.engine.NadelExecutionContext @@ -8,14 +7,12 @@ import graphql.nadel.engine.NadelServiceExecutionContext import graphql.nadel.engine.blueprint.NadelBatchHydrationFieldInstruction import graphql.nadel.engine.blueprint.NadelGenericHydrationInstruction import graphql.nadel.engine.blueprint.NadelOverallExecutionBlueprint -import graphql.nadel.engine.transform.NadelTransform import graphql.nadel.engine.transform.artificial.NadelAliasHelper import graphql.nadel.engine.transform.partition.NadelFieldPartitionContext import graphql.nadel.engine.transform.partition.NadelPartitionKeyExtractor import graphql.nadel.engine.transform.partition.NadelPartitionTransformHook import graphql.nadel.engine.transform.result.json.JsonNode import graphql.normalized.ExecutableNormalizedField -import graphql.schema.GraphQLInputValueDefinition import kotlinx.coroutines.future.await import java.util.concurrent.CompletableFuture @@ -23,21 +20,6 @@ import java.util.concurrent.CompletableFuture * These hooks allow you to change the way service execution happens */ interface NadelExecutionHooks { - /** - * 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) } diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/service-context-is-being-set.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/service-context-is-being-set.kt deleted file mode 100644 index 25a100e9f..000000000 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/service-context-is-being-set.kt +++ /dev/null @@ -1,36 +0,0 @@ -package graphql.nadel.tests.hooks - -import graphql.nadel.Nadel -import graphql.nadel.ServiceExecution -import graphql.nadel.ServiceExecutionFactory -import graphql.nadel.hooks.CreateServiceContextParams -import graphql.nadel.hooks.NadelExecutionHooks -import graphql.nadel.tests.EngineTestHook -import graphql.nadel.tests.UseHook -import graphql.nadel.tests.util.serviceExecutionFactory -import java.util.concurrent.CompletableFuture - -@UseHook -class `service-context-is-being-set` : EngineTestHook { - override fun makeNadel(builder: Nadel.Builder): Nadel.Builder { - val serviceExecutionFactory = builder.serviceExecutionFactory - - return builder - .executionHooks(object : NadelExecutionHooks { - override fun createServiceContext(params: CreateServiceContextParams): CompletableFuture { - return CompletableFuture.completedFuture("Context for ${params.service.name}") - } - }) - .serviceExecutionFactory(object : ServiceExecutionFactory by serviceExecutionFactory { - override fun getServiceExecution(serviceName: String): ServiceExecution { - val default = serviceExecutionFactory.getServiceExecution(serviceName) - - return ServiceExecution { params -> - assert(params.getServiceContext() == "Context for MyService") - - default.execute(params) - } - } - }) - } -} diff --git a/test/src/test/resources/fixtures/basic/service-context-is-being-set.yml b/test/src/test/resources/fixtures/basic/service-context-is-being-set.yml deleted file mode 100644 index 330630725..000000000 --- a/test/src/test/resources/fixtures/basic/service-context-is-being-set.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: "service context is being set" -enabled: true -# language=GraphQL -overallSchema: - MyService: | - type Query { - foo: String - } -# language=GraphQL -underlyingSchema: - MyService: | - type Query { - foo: String - } -# language=GraphQL -query: | - query { - foo - } -variables: { } -serviceCalls: - - serviceName: "MyService" - request: - # language=GraphQL - query: | - query { - foo - } - variables: { } - # language=JSON - response: |- - { - "data": { - "foo": null - }, - "extensions": {} - } -# language=JSON -response: |- - { - "data": { - "foo": null - }, - "extensions": {} - }