spring-graphql
spring-graphql copied to clipboard
Is it possible to retrieve a HandlerMethod somewhere between interceptors.
What I would like to achieve is getting a HandlerMethod, annotated with @Controller before it executes.
I can achieve this in SpringBoot by extending HandlerInterceptor and casting the handler to HandlerMethod.
For example:
public class CustomHandlerInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (handler instanceof HandlerMethod handlerMethod){
Method method = handlerMethod.getMethod();
CustomAnnonation controller = AnnotationUtils.findAnnotation(handlerMethod.getMethod().getDeclaringClass(), CustomAnnonation.class);
CustomAnnonation method = handlerMethod.getMethodAnnotation(CustomAnnonation.class);
...
}
return true;
}
}
Is there an easy way do the same with graphql as well