0

试图跟随Hotchocolate ChilliCream 博客

基本 GraphQl 服务器运行正常。但是,当我按照博客中的说明添加模式拼接时,无法构建项目。我的包裹参考如下;

<PropertyGroup>
      <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
      <PackageReference Include="GraphQL.Server.Ui.Voyager" Version="4.4.1" />
      <PackageReference Include="HotChocolate.Abstractions" Version="11.0.9" />
      <PackageReference Include="HotChocolate.AspNetCore" Version="11.0.9" />
      <PackageReference Include="HotChocolate.Data.EntityFramework" Version="11.0.9" />
      <PackageReference Include="HotChocolate.Stitching" Version="11.0.9" />
      <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          <PrivateAssets>all</PrivateAssets>
      </PackageReference>
      <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
  </ItemGroup>

并尝试添加

      services.AddStitchedSchema(builder => builder
              .AddSchemaFromHttp("messages")
              .AddSchemaFromHttp("users")
              .AddSchemaFromHttp("analytics"));

发生以下构建错误;

Severity    Code    Description Project File    Line    Suppression State
Error   CS1061  'IServiceCollection' does not contain a definition for 'AddStitchedSchema' and no accessible extension method 'AddStitchedSchema' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)  GraphQL.WebApi  C:\github\.net5.0_graphql_hotchocolate\GraphQL.WebApi\Startup.cs    46  Active

如何在这个项目中添加模式拼接?

4

1 回答 1

2

模式构建器已合并为一个。

你可以做

 services
     .AddGraphQLServer()
     .AddRemoteSchema("messages")
     .AddRemoteSchema("users")

此 PR 是 WIP 文档: https ://github.com/ChilliCream/hotchocolate/pull/2780

于 2021-03-21T17:05:46.813 回答