简体   繁体   中英

Enable or disable async mode in Spring for GraphQL (WebMvc)

Using org.springframework.boot:spring-boot-starter-graphql and WebMvc, I have the following error while running the query: Caused by: java.lang.IllegalStateException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml. Caused by: java.lang.IllegalStateException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml.

  1. Can we disable async mode in Spring for GraphQL?
  2. In case not, how to enable async-supported in Spring for the GraphQL endpoint?

Asynchronous dispatch cannot be disabled with a simple property and it is not advised, as GraphQL Java uses the AsyncExecutionStrategy by default. I'd say this is quite central in a GraphQL approach, where parts of the schema can be resolved from multiple sources (data stores, web APIs, etc) and the engine optimizes that.

If you're getting this error, this means you've configured a custom filter that is not configured for async support (and still mapped for ASYNC dispatch). In general, you should review your entire filters/Servlet/container arrangement to check for that. Ideally, you could start from a new https://start.spring.io and add custom filters and config one by one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM