热巧克力 GraphQL - MaxExecutionDepth 不工作
Hot Chocolate GraphQL - MaxExecutionDepth not working
如何让 MaxExecutionDepth
在 Hot Chocolate GraphQL 中工作?这是我的代码:
// Add GraphQL Services
services.AddGraphQL(
SchemaBuilder.New()
// enable for authorization support
.AddAuthorizeDirectiveType()
.ModifyOptions(o => o.RemoveUnreachableTypes = true)
.Create()
.MakeExecutable(
builder =>
builder
.UseDefaultPipeline()
.AddErrorFilter<UseExceptionMessageErrorFilter>()
.AddOptions(
new QueryExecutionOptions()
{
MaxExecutionDepth = 15
}))
.Schema);
我已经对此进行了测试,甚至将 MaxExecutionDepth
更改为 1,但我仍然可以执行 20 多个深度查询。
根据 GitHub issue I created 中的开发人员的说法,能够让它像这样工作:
services.AddGraphQL(
SchemaBuilder.New()
// enable for authorization support
.AddAuthorizeDirectiveType()
.ModifyOptions(o => o.RemoveUnreachableTypes = true)
.Create(),
new QueryExecutionOptions()
{
MaxExecutionDepth = ApiConfigurationConstants.MaxExecutionDepth
});
services.AddErrorFilter<UseExceptionMessageErrorFilter>();
如何让 MaxExecutionDepth
在 Hot Chocolate GraphQL 中工作?这是我的代码:
// Add GraphQL Services
services.AddGraphQL(
SchemaBuilder.New()
// enable for authorization support
.AddAuthorizeDirectiveType()
.ModifyOptions(o => o.RemoveUnreachableTypes = true)
.Create()
.MakeExecutable(
builder =>
builder
.UseDefaultPipeline()
.AddErrorFilter<UseExceptionMessageErrorFilter>()
.AddOptions(
new QueryExecutionOptions()
{
MaxExecutionDepth = 15
}))
.Schema);
我已经对此进行了测试,甚至将 MaxExecutionDepth
更改为 1,但我仍然可以执行 20 多个深度查询。
根据 GitHub issue I created 中的开发人员的说法,能够让它像这样工作:
services.AddGraphQL(
SchemaBuilder.New()
// enable for authorization support
.AddAuthorizeDirectiveType()
.ModifyOptions(o => o.RemoveUnreachableTypes = true)
.Create(),
new QueryExecutionOptions()
{
MaxExecutionDepth = ApiConfigurationConstants.MaxExecutionDepth
});
services.AddErrorFilter<UseExceptionMessageErrorFilter>();