From 36f2414bb99216a5dca8aa3fff6166ba3606746e Mon Sep 17 00:00:00 2001 From: oliemansm Date: Sun, 21 Feb 2021 14:29:35 +0100 Subject: [PATCH] Reinstate the async mode enabled property fix #540 --- README.md | 24 +++++++++++-------- .../web/boot/GraphQLServletProperties.java | 1 + .../web/boot/GraphQLWebAutoConfiguration.java | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 08af963a..1f78f2ed 100644 --- a/README.md +++ b/README.md @@ -228,16 +228,20 @@ or `application.properties`): ```yaml graphql: - servlet: - mapping: /graphql - enabled: true - corsEnabled: true - cors: - allowed-origins: http://some.domain.com - allowed-methods: GET, HEAD, POST - # if you want to @ExceptionHandler annotation for custom GraphQLErrors - exception-handlers-enabled: true - contextSetting: PER_REQUEST_WITH_INSTRUMENTATION + servlet: + # Sets if GraphQL servlet should be created and exposed. If not specified defaults to "true". + enabled: true + # Sets the path where GraphQL servlet will be exposed. If not specified defaults to "/graphql" + mapping: /graphql + cors-enabled: true + cors: + allowed-origins: http://some.domain.com + allowed-methods: GET, HEAD, POST + # if you want to @ExceptionHandler annotation for custom GraphQLErrors + exception-handlers-enabled: true + context-setting: PER_REQUEST_WITH_INSTRUMENTATION + # Sets if asynchronous operations are supported for GraphQL requests. If not specified defaults to true. + async-mode-enabled: true ``` By default a global CORS filter is enabled for `/graphql/**` context. The `corsEnabled` can be set diff --git a/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLServletProperties.java b/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLServletProperties.java index 0595ef1a..f9b41941 100644 --- a/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLServletProperties.java +++ b/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLServletProperties.java @@ -36,6 +36,7 @@ public class GraphQLServletProperties { private long subscriptionTimeout = 0; private ContextSetting contextSetting = ContextSetting.PER_QUERY_WITH_INSTRUMENTATION; private long asyncTimeout = 30000; + private boolean asyncModeEnabled = true; private String tracingEnabled = "false"; private boolean actuatorMetrics; private Integer maxQueryComplexity; diff --git a/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLWebAutoConfiguration.java b/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLWebAutoConfiguration.java index c7db68e6..b58242bd 100644 --- a/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLWebAutoConfiguration.java +++ b/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLWebAutoConfiguration.java @@ -329,6 +329,7 @@ public ServletRegistrationBean graphQLServletRegistr } else { registration.setMultipartConfig(new MultipartConfigElement("")); } + registration.setAsyncSupported(graphQLServletProperties.isAsyncModeEnabled()); return registration; }