How to configure GraphQLContext in kickstart GraphQLHttpServlet as getContext() is deprecated in graphql-java #438
Unanswered
David-Java-stack
asked this question in
Q&A
Replies: 1 comment 1 reply
-
This was not supported yet in v12. Since v13 you can get the request from the context like this: public InstrumentationContext beginExecution(InstrumentationExecutionParameters parameters) {
GraphQlContext context = parameters.getGraphQlContext();
HttpServletRequest request = context.get(HttpServletRequest.class); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I implemented Instrumentation and using parameters.getContext() to get authentication , however , since now, getContext() is deprecated , I tried to use getGraphQLContext() instead but it returning empty object , what should I do ?
thx
@slf4j
@requiredargsconstructor
public class RequestLoggingInstrumentation extends SimpleInstrumentation {
@OverRide
public InstrumentationContext beginExecution(
InstrumentationExecutionParameters parameters) {
GraphQLServletContext context = parameters.getContext();
HttpServletRequest request = context.getHttpServletRequest();
KeycloakSecurityContext keycloakSecurityContext = (KeycloakSecurityContext)
request.getAttribute(KeycloakSecurityContext.class.getName());
I'm configuring the servlet and configuration as following:
@bean
public ServletRegistrationBean partyGraphQLServletRegistration() {
GraphQLHttpServlet servlet = GraphQLHttpServlet.with(getGraphQLConfiguration());
return new ServletRegistrationBean<>(servlet, url);
}
as u can see I tried to add CustomGraphQLContextBuilder() , however , it appears in getContext() method
but getGraphQLContext() is still empty map
any idea?
thx
Beta Was this translation helpful? Give feedback.
All reactions