Anders Kirkeby
02/17/2021, 3:08 PMDariusz Kuc
02/17/2021, 3:28 PMThreadLocals
to store it (which MDC relies on). With WebFlux (which we use in graphql-kotlin-spring-server
) you have reactor subscriber context (and coroutine context through interop).graphql-java
execution logic we jump between reactor/coroutines and CompletableFuture
which don't have any contextual information.
One way to solve it is to create your custom GraphQLServer
(https://github.com/ExpediaGroup/graphql-kotlin/blob/master/servers/graphql-kotlin-[…]tlin/com/expediagroup/graphql/server/execution/GraphQLServer.kt) which populates MDC (and other contextual data) and then wraps the execution in your coroutine context. You then would also need to create custom DataFetcher
(I'd extend https://github.com/ExpediaGroup/graphql-kotlin/blob/master/generator/graphql-kotli[…]expediagroup/graphql/generator/execution/FunctionDataFetcher.kt) that propagates the coroutine context when invoking suspendable functions.Anders Kirkeby
02/17/2021, 3:33 PMDariusz Kuc
02/17/2021, 3:34 PMAnders Kirkeby
02/17/2021, 3:35 PMRobert
03/20/2021, 8:18 AM