How to access HttpServletRequest from Spring for Graphql WebGraphQlInterceptor

46 views Asked by At

I am working on moving to Spring for GraphQL from kickstarter. And we used a custom Context in kickstart implementing GraphQLKickstartContext. However, this is not supported in Spring for GraphQl and we want to add some headers, parameters and attributes from HttpServletRequest to the GraphQLContext. Appreciate your help.

Trial: In the WebGraphQlInterceptor, you can access the Headers, but not the parameters nor the attributes (accessing debug parameter, security.web.username attribute etc.)

1

There are 1 answers

0
Brian Clozel On

Spring for GraphQL won't give you access to the actual HTTP request implementation, as this WebGraphQlInterceptor contract is meant to be used by Servlet and non-Servlet environments.

Looking at WebGraphQlRequest, this should contain everything you need already:

  • HTTP headers
  • URI
  • cookies
  • request attributes