标签: nestjs-graphql

Nestjs + apollo graphql 联合网关由于“错误请求”而无法内省服务,可复制的 git 存储库可用

在 NX monorepo 中,我正在构建 3 个 Nestjs 应用程序,首先是一个auth-service+user-service和一个。gateway它们均由 apollo graphql 提供支持并遵循官方 Nestjs 文档。

我遇到的问题是,在user-service作为auth-service单独服务器成功处理请求的同时,网关抛出

 Couldn't load service definitions for "auth" at http://localhost:3100/apis/auth-service/graphql: 400: Bad Request
Run Code Online (Sandbox Code Playgroud)

这些服务本身是标准的 graphql 应用程序,没有什么基础的。

网关的定义如下:

{
server: {
          debug: true,
          playground: true,
          autoSchemaFile: './apps/gateway/schema.gql',
          sortSchema: true,
          introspection: true,
          cors: ['*'],
          path: '/apis/gateway/graphql';
        },
gateway: {
            supergraphSdl: new IntrospectAndCompose({
              subgraphHealthCheck: true,
              subgraphs: [
                {
                  name: 'user',
                  url: resolveSubgraphUrl('user'),
                },
                {
                  name: 'auth',
                  url: resolveSubgraphUrl('auth'),
                },
              ],
            }), …
Run Code Online (Sandbox Code Playgroud)

graphql nestjs apollo-federation graphql-federation nestjs-graphql

6
推荐指数
0
解决办法
489
查看次数