Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customize async running or fully disable library async logic. #563

Open
nathanmolinari opened this issue Apr 1, 2024 · 0 comments

Comments

@nathanmolinari
Copy link

Is your feature request related to a problem? Please describe.

I would like to code something like this, if operation is x, then execute in threadpool y. But the library do not give me this flexibility, i can only inform one threadpool that all async tasks will run.

Describe the solution you'd like

I would like that i can set my own HttpRequestHandlerImpl and HttpRequestInvokerImpl where i'm going to code my execution logic with fully flexibility to choose which threadpool i`m going to use to each scenario.

Also change the visibility of methods from HttpRequestInvokerImpl, by doing this, i can code something like

	public class MyHttpRequestInvokerImpl extends HttpRequestInvokerImpl {
		@Override
		public void execute(
				GraphQLInvocationInput invocationInput,
				HttpServletRequest request,
				HttpServletResponse response,
				ListenerHandler listenerHandler) {

			if(someLogic) {
				runAsync(myThreadPool, super.handle(invocationInput, request, response, listenerHandler));
			} else {
				super.execute(...args)
			}
		}

	}

Other option would be to check on HttpRequestInvokerImpl.java#L45 if property graphql.servlet.async.enabled is true. If not the library should not execute tasks async. By doing this, i can fully disable library async logic, and code a customized one.

Describe alternatives you've considered

Before async support (older versions) we coded by ourselves async running. When upgraded the async logic just broke because the library try to run async again when isAsyncSupported() returns true.
https://github.com/graphql-java-kickstart/graphql-java-servlet/blob/master/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/HttpRequestInvokerImpl.java#L45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant