【问题标题】:.net 5.0 hotchocolate graphql server version 11 where is schema stiching?.net 5.0 hotchocolate graphql server version 11 模式拼接在哪里?
【发布时间】:2021-03-21 16:48:01
【问题描述】:

尝试关注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

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

【问题讨论】:

    标签: asp.net-core graphql hotchocolate


    【解决方案1】:

    架构构建器已合并为一个。

    你可以这样做

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

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

    【讨论】:

      猜你喜欢
      • 2021-10-30
      • 2018-04-23
      • 1970-01-01
      • 2018-12-27
      • 2021-07-16
      • 2021-06-09
      • 2020-09-07
      • 2022-11-07
      • 2018-11-08
      相关资源
      最近更新 更多