Spring WebFlux - WebGraphQlInterceptor has empty request data

Viewed 19

I would need to retrieve data from query headers for use in the GraphQl query controller. I searched around a bit and found the WebGraphQlInterceptor, but realized that when the WebGraphQlRequest argument is invoked it is completely devoid of information.

For example, this code:

@Component
class WebRequestInterceptor : WebGraphQlInterceptor {
    val logger: Logger by lazy { LoggerFactory.getLogger(WebRequestInterceptor::class.java) }

    override fun intercept(request: WebGraphQlRequest, chain: WebGraphQlInterceptor.Chain): Mono<WebGraphQlResponse> {
        logger.info("URI", request.uri.toString())
        logger.info("HEADERS", request.headers.toString())
        logger.info("DOCUMENT", request.document)
        return chain.next(request)
    }
}

Returns:

2022-09-12 10:57:11.747  INFO 1 --- [or-http-epoll-1] b.s.b.gateway.auth.WebRequestInterceptor      : URI *empty string*
2022-09-12 10:57:11.748  INFO 1 --- [or-http-epoll-1] b.s.b.gateway.auth.WebRequestInterceptor      : HEADERS *empty string*
2022-09-12 10:57:11.748  INFO 1 --- [or-http-epoll-1] b.s.b.gateway.auth.WebRequestInterceptor      : DOCUMENT *empty string*

P.S. The same thing happens if I try to log a single headers element using the request.headers.getFirst(..) function.

0 Answers
Related