How to set Execution Timeout in Hotchocolate 10.4.3

4.3k views Asked by At

we are using Hotchocolate 10.4.3 for my .net core service. we are using code first approach. All settings are in startup.cs exactly similar to their Star War example. Hotchocolate web site says default timeout for request is 30 sec but I found my application throwing Transaction error after 1 min. I want to increase that to 2 min.

Also why server still executes everything even after timeout exception. I always see Transaction error at end after all my code gets execute properly.

If everything is going to run properly why to even then throw error?

I'm still learning graphql. Please correct me if anything sounds incorrect.

1

There are 1 answers

0
ngprice On

In HotChocolate v10, you can set the execution timeout when you add the service in your Startup's ConfigureServices() method:

services.AddGraphQL(
    SchemaBuilder.New()
        .AddQueryType<Query>()
        .Create(),
    new QueryExecutionOptions { ExecutionTimeout = TimeSpan.FromMinutes(2) });

They have a good repo of examples here: https://github.com/ChilliCream/hotchocolate-examples

Documentation on the execution options: https://chillicream.com/docs/hotchocolate/v10/execution-engine/execution-options

EDIT: In v11, the syntax has changed:

services
    .AddGraphQLServer()
    .AddQueryType<Query>()
    .SetRequestOptions(_ => new HotChocolate.Execution.Options.RequestExecutorOptions { ExecutionTimeout = TimeSpan.FromMinutes(10) });