Servlet Filter with ThreadLocal in Netflix DGS

432 Views Asked by At

Stack: Spring Boot: 2.4.5 DGS: 3.11.0

Case: There is a need to filter each request and read from it HTTP headers. The value from the headers should be accessible in downstream code which processes the GraphQL request. A common approach could be to use the Servlet filter with ThreadLocal for storing those values.

Issue: DGS is using CompletableFutures to process the incoming GraphQL requests, so even if the filter is set up and the data is read to the ThreadLocal it won't be available in the execution thread of DGS.

What would be recommended ways to resolve this kind of issue?

0

There are 0 best solutions below