11# Async timeout
22
3- The ` graphql.servlet.async- timeout ` property enables you to define a request level timeout to be enforced. This can help
3+ The ` graphql.servlet.async. timeout ` property enables you to define a request level timeout to be enforced. This can help
44in preventing DDoS attacks. This is only available when running the application in ` servlet ` mode. The value is the
55timeout in milliseconds that should be enforced. If the GraphQL request has not finished within that timeout a GraphQL
66error will be returned:
@@ -30,12 +30,9 @@ In this example the timeout has been configured at 500 milliseconds in
3030[ application.yml] ( src/main/resources/application.yml ) .
3131
3232``` yaml
33- graphql.servlet.async- timeout : 500
33+ graphql.servlet.async. timeout : 500
3434` ` `
3535
36- Note that the property ` graphql.servlet.async-mode-enabled` has not been set to `true` here, because that's it's enabled
37- by default already.
38-
3936## GraphQL execution cancellation
4037
4138The [Query](src/main/java/com/graphql/sample/boot/Query.java) class shows two examples of queries that will take 3000
@@ -59,11 +56,11 @@ query {
5956
6057Either one will stop processing after 500ms because of the configured timeout.
6158
62- The main difference between the two methods in the `Query` class however is the ability to also cancel the execution of
59+ ~~ The main difference between the two methods in the ` Query ` class however is the ability to also cancel the execution of
6360the GraphQL request. Ideally the GraphQL execution is cancelled as well, because otherwise that request is still taking
6461up resources and Thread(s) even though the HTTP request has stopped. An attacker could repeatedly call that particular
6562GraphQL query which now returns fast, and that would spawn a new Thread with long running execution within the
66- application itself. That could ultimately lead to an application that crashes because it runs out of memory for example.
63+ application itself. That could ultimately lead to an application that crashes because it runs out of memory for example.~~
6764
6865To make the GraphQL requests themselves cancellable you only have to remember to always return a ` CompletableFuture `
6966instead of the value directly. The ` Query.getHello() ` method is a simple example of a cancellable GraphQL request.
0 commit comments