1

目前正在使用 ASP.Net Web Api 作为我们其他 graphql 微服务的网关。我们正在使用 Hot Chocolate 10.5.2 将所有模式定义拼接在一起。我们的大多数模式都可以正常工作;但是,当我们尝试拼接多个查询模式时,它不会为下游微服务生成可使用的模式。如果我们直接调用下游微服务,则此查询可以正常工作,但不能通过网关 api 使用拼接模式。

查询如下:

query getComments($pKId: String!, $exceptionId: String!, $exceptionType: String!, $exclusiveStartKey: PaginationInput) 
{
    comments: comments(commentData: {pKId: $pKId, minimum: 100, order: "Descending", exclusiveStartKey: $exclusiveStartKey}) 
    {
        rows: comments 
        {
            commentId: sKId
            userName: createdByName
            subId: createdBySubId
            comment: commentText
            createdTimeStamp: createdTimeStamp
            lastUpdatedTimeStamp: lastUpdatedTimeStamp
            __typename
        }
        lastEvaluatedKey 
        {
            pKId
            sKId
            __typename
        }
        __typename
    }

    exception: exceptions(exceptionData: {sKId: $exceptionId, exceptionType: $exceptionType, limit: 1})
    {
        detail: exceptions 
        {
            commentCount: commentCount
            __typename
        }
        __typename
    }
}

据我所知,RemoteRequestDispatcher 将查询变量重命名为__0__variablenameetc,但即使名称相同,它似乎也没有重命名传入的对象的属性。这导致我们在遇到下游微服务时收到以下错误:

"errors": [
    {
      "message": "The following variables were not used: __0__pKId, __0__exclusiveStartKey, __1__exceptionId, __1__exceptionType.",
      "locations": [
        {
          "line": 1,
          "column": 1
        }
      ],
      "extensions": {
        "remote": "HotChocolate.Error",
        "schemaName": "stockrecord"
      }
    },
    {
      "message": "The following variables were not declared: pKId, exclusiveStartKey, exceptionId, exceptionType.",
      "locations": [
        {
          "line": 1,
          "column": 1
        }
      ],
      "extensions": {
        "remote": "HotChocolate.Error",
        "schemaName": "stockrecord"
      }
    },

因此,重命名的变量显示为未使用,并且由于重命名,未声明作为输入对象一部分的变量。

我意识到我们可以改变我们传递变量的方式,但由于这是一个有效的模式,无需拼接就可以直接工作,我们宁愿不必更改所有的 UI 代码。

任何帮助,将不胜感激!

4

0 回答 0