【问题标题】:HotChocolate GraphQL Configure not being calledHotChocolate GraphQL 配置未被调用
【发布时间】:2020-06-16 02:31:20
【问题描述】:

我有一个问题:

public class Query : ObjectType
{
    protected override void Configure(IObjectTypeDescriptor<Query> descriptor)
    {
        Console.WriteLine("Hit Configure");
    }

    public IQueryable<DataStory> GetDataStories([Service]MicipContext context)
    {
        return context.DataStories;
    }
}

在 Startup.cs 中:

public void ConfigureServices(IServiceCollection services)
{
    services.AddGraphQL(sp =>
    {
        var schema = SchemaBuilder.New()
            .AddDocumentFromString(this.ReadSchema())
            .BindResolver<Query>(c => c.To<Query>())
            .AddServices(sp)
            .Create();
        return schema;
    }
}

还有我的模式 graphql:

type Query {
  dataStories: [DataStory!]!
}

type DataStory {
  id: Int!
  title: String!
}

当我调用查询时:

query GetDataStories {
    dataStories {
        title
    }
}

解析器正确返回,但我的配置方法从未被调用。我究竟做错了什么?不应该在某个时候调用 Configure 吗?

【问题讨论】:

    标签: graphql hotchocolate


    【解决方案1】:

    发现 Hot Chocolate 没有在模式优先项目上添加对分页/排序/过滤器的支持。我们先做模式,所以我们必须自己实现它。

    【讨论】:

      猜你喜欢
      • 2022-11-07
      • 1970-01-01
      • 2021-11-25
      • 2021-09-05
      • 2021-07-16
      • 1970-01-01
      • 2019-11-25
      • 2022-10-19
      • 1970-01-01
      相关资源
      最近更新 更多