Search code examples
asp.net-coregraphqlhotchocolate

.net 5.0 hotchocolate graphql server version 11 where is schema stiching?


Trying to follow along Hotchocolate ChilliCream blog

Basic GraphQl server runs OK. However, when I add schema stiching as instructed in the blog, couldn't build the project. My package references as below;

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

and try to add

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

below build error happens;

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

How to add schema stiching in this project?


Solution

  • The schema builders have been combined to a single one.

    You can just do

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

    This PR is the WIP docs: https://github.com/ChilliCream/hotchocolate/pull/2780