简体   繁体   中英

How to set Execution Timeout in Hotchocolate 10.4.3

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.

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) });

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