簡體   English   中英

在 Spring 中為 GraphQL (WebMvc) 啟用或禁用異步模式

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

使用org.springframework.boot:spring-boot-starter-graphql和 WebMvc,我在運行查詢時出現以下錯誤: 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. 我們可以在 Spring 中為 GraphQL 禁用異步模式嗎?
  2. 如果沒有,如何為 GraphQL 端點啟用 Spring 中的async-supported

異步調度無法通過簡單的屬性禁用,因此不建議這樣做,因為 GraphQL Java 默認使用AsyncExecutionStrategy 我想說這在 GraphQL 方法中非常重要,其中部分模式可以從多個來源(數據存儲、web API 等)解析,並且引擎會對其進行優化。

如果您收到此錯誤,這意味着您配置了一個自定義過濾器,該過濾器未配置為異步支持(並且仍然映射為 ASYNC 調度)。 一般來說,你應該檢查你的整個過濾器/Servlet/容器安排來檢查。 理想情況下,您可以從新的https://start.spring.io開始,並一一添加自定義過濾器和配置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM