Context
While ArianeServer receives an incoming request, it triggers the context function and pass it output to each visited resolver.
You can pass this function like this
arianeServer {
context { httpRequest ->
//You must return a `GraphQLContext` like this
GraphQLContext.of(
mapOf(
"session" to UserSession(httpRequest.headers["Authorization"])
)
)
}
}.launch()
You can now use the returned object in your resolver
resolvers {
Mutation {
resolve("addMovie") {
val userBearerToken = context["session"]?.token
// You can throw an error if the session is invalid
}
}
}