【问题标题】:Hot Chocolate GraphQL - MaxExecutionDepth not working热巧克力 GraphQL - MaxExecutionDepth 不起作用
【发布时间】:2020-08-21 13:06:08
【问题描述】:

如何让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 多个深度查询。

【问题讨论】:

  • 您是否尝试过移动Create call中的使用设置
  • @GuruStron 不确定你的意思; Create() 没有参数。
  • 哦,我看错了 API,抱歉。
  • 添加了答案,请尝试一下。

标签: c# .net-core graphql hotchocolate


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2022-10-25
    • 2020-12-22
    • 2022-01-10
    • 2021-11-24
    • 2021-09-09
    • 1970-01-01
    • 2022-01-04
    • 2020-11-13
    • 2022-07-28
    相关资源
    最近更新 更多