Hotchocolate graphql 未在 Apollo Federation 下作为子图运行

发布于 2025-01-12 09:17:26 字数 2818 浏览 1 评论 0原文

我正在尝试使用 .net 5.0 将 hotchocolate 12 子图添加到我现有的 Apollo 联邦中。不幸收到

(node:27900) UnhandledPromiseRejectionWarning: Error: Couldn't load service definitions for "supplier" at http://localhost:3003/graphql: 400: Bad Request
    at C:\dev\git\dev.to\graphql.net-in-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagers\IntrospectAndCompose\loadSer    at C:\dev\git\dev.to\graphql.net-in-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagers\Introsp
vicesFromRemoteEndpoint.ts:77:15
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Promise.all (index 0)
    at loadServicesFromRemoteEndpoint (C:\dev\git\dev.to\graphql.net-in-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagy\src\supergraphManagers\IntrospectAndCompose\loadServicesFromRemoteEndpoint.ts:81:30)

csprojstartup.cs

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
      <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="graphiql" Version="2.0.0" />
    <PackageReference Include="HotChocolate.Abstractions" Version="12.6.2" />
      <PackageReference Include="HotChocolate.AspNetCore" Version="12.6.2" />    
    <PackageReference Include="HotChocolate.ApolloFederation" Version="12.6.2" />    
  </ItemGroup>
</Project>

 public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {   
            services
                .AddGraphQLServer()
                .AddApolloFederation()
                .AddQueryType<Query>();                 

            services.AddGraphiQl(x =>
            {
                x.GraphiQlPath = "/graphiql-ui";
                x.GraphQlApiPath = "/graphql";
            });

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            app.UseGraphiQl();
                   
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGraphQL();
            });

        }

示例项目 https://github.com/killjoy2013/hotchocolate-apollo-federation

什么我失踪了吗?

I'm trying to add a hotchocolate 12 subgraph to my existing Apollo federation using .net 5.0. Unfortunately receiving

(node:27900) UnhandledPromiseRejectionWarning: Error: Couldn't load service definitions for "supplier" at http://localhost:3003/graphql: 400: Bad Request
    at C:\dev\git\dev.to\graphql.net-in-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagers\IntrospectAndCompose\loadSer    at C:\dev\git\dev.to\graphql.net-in-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagers\Introsp
vicesFromRemoteEndpoint.ts:77:15
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Promise.all (index 0)
    at loadServicesFromRemoteEndpoint (C:\dev\git\dev.to\graphql.net-in-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagy\src\supergraphManagers\IntrospectAndCompose\loadServicesFromRemoteEndpoint.ts:81:30)

csproj

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
      <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="graphiql" Version="2.0.0" />
    <PackageReference Include="HotChocolate.Abstractions" Version="12.6.2" />
      <PackageReference Include="HotChocolate.AspNetCore" Version="12.6.2" />    
    <PackageReference Include="HotChocolate.ApolloFederation" Version="12.6.2" />    
  </ItemGroup>
</Project>

startup.cs;

 public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {   
            services
                .AddGraphQLServer()
                .AddApolloFederation()
                .AddQueryType<Query>();                 

            services.AddGraphiQl(x =>
            {
                x.GraphiQlPath = "/graphiql-ui";
                x.GraphQlApiPath = "/graphql";
            });

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            app.UseGraphiQl();
                   
            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGraphQL();
            });

        }

Sample project https://github.com/killjoy2013/hotchocolate-apollo-federation

What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文