.net 5.0 hotchocolate graphql 服务器版本 11 哪里是模式拼接?

问题描述

努力跟上Hotchocolate ChilliCream blog

基本 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

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

解决方法

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

你可以这样做

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

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...