0

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

4

1 回答 1

1

根据我创建的 GitHub 问题中的开发人员,能够让它像这样工作:

            services.AddGraphQL(
                SchemaBuilder.New()
                    // enable for authorization support
                    .AddAuthorizeDirectiveType()
                    .ModifyOptions(o => o.RemoveUnreachableTypes = true)
                    .Create(),
                new QueryExecutionOptions()
                {
                    MaxExecutionDepth = ApiConfigurationConstants.MaxExecutionDepth
                });
            services.AddErrorFilter<UseExceptionMessageErrorFilter>();
于 2020-05-07T15:49:32.210 回答