'GraphQL + Springboot + Http Headers
I'm using these graphql dependencies:
"com.graphql-java-kickstart:graphql-spring-boot-starter:12.0.0",
"com.graphql-java-kickstart:graphql-java-tools:12.0.0",
And how can I get httpRequestHeaders from the DataFetchingEnvironment class. I see DataFetchingEnvironment.getContext()
is deprecated is there any other alternative?
Current logic:
GraphQLServletContext servletContext = env.getContext(); //deprecated
GraphQLContext qlContext = env.getGraphQlContext(); // No httpRequest
var httpRequest = servletContext.getHttpServletRequest();
Solution 1:[1]
You can do:
env.getGraphQlContext().get(HttpServletRequest.class).getHeader("header")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |