graphql.nadel.enginekt.NadelExecutionContext.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nadel-engine-nextgen Show documentation
Show all versions of nadel-engine-nextgen Show documentation
Nadel is a Java library that combines multiple GrahpQL services together into one API.
The newest version!
package graphql.nadel.enginekt
import graphql.ExecutionInput
import graphql.PublicApi
import graphql.nadel.NadelExecutionHints
import graphql.nadel.Service
import graphql.nadel.hooks.CreateServiceContextParams
import graphql.nadel.hooks.ServiceExecutionHooks
import graphql.normalized.ExecutableNormalizedOperation
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ConcurrentHashMap
@PublicApi
data class NadelExecutionContext(
val executionInput: ExecutionInput,
val query: ExecutableNormalizedOperation,
val hooks: ServiceExecutionHooks,
val hints: NadelExecutionHints,
) {
private val serviceContexts = ConcurrentHashMap>()
val userContext: Any?
get() {
return executionInput.context
}
/**
* Get the service context for a given service
*/
fun getContextForService(service: Service): CompletableFuture {
return serviceContexts.getOrPut(service.name) {
hooks.createServiceContext(
CreateServiceContextParams(service)
)
}
}
}