如何为所有查询请求永久启用带有热巧克力的Apollo跟踪?

时间:2019-02-06 20:31:17

标签: c# .net .net-core graphql

Hot Chocolate .Net Core 一起使用时,我正在创建以下方案:

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // Here I register my services / repositories; omitted for brevity

        services.AddGraphQL(sp => Schema.Create(c =>
        {
            // Here I register my schema types and so on; omitted for brevity
        }));
    }

     // Code omitted for brevity
}

但是实际上如何为所有请求启用内置的 Apollo跟踪?它可以和 .Net Framework 一起使用吗?

1 个答案:

答案 0 :(得分:3)

基本上,将TracingPreference选项设置为TracingPreference.Always

下面的代码片段显示了它的样子。

services.AddGraphQL(sp => Schema.Create(c =>
{
    // Here goes the schema definition which is omitted for brevity purpose
}),
new QueryExecutionOptions
{
    TracingPreference = TracingPreference.Always
});

是的,它在.Net Framework中的工作方式相同。 .Net Core和Framework中的API保持相同,可以说99%相同。这里的区别仅在于周围环境,这意味着包装了DI配置的Startup类。

有关阿波罗追踪的更多信息,请前往here

相关问题