首页 > 解决方案 > CraftQL - 无法在矩阵字段中找到标签字段

问题描述

我有一个矩阵字段,里面有一个“标签”字段:

矩阵字段定义.

我正在使用 CraftQL 来获取此条目中的所有字段,并且通常它工作得非常好,除了那个标签字段。

当我在管理面板的 CraftQL 控制台中运行以下查询时,theBasicsIndustries按预期返回标签数组。

query StoryQuery($slug: String!) {
    entry(siteId: 2, slug: $slug) {
      ... on StoriesStory {
        id
        contentBlock {
          ... on ContentBlockTheBasics {
            __typename
            id
            theBasicsName                

            theBasicsIndustries {
              id
              title
            }
          }       
        }
      }
    }
  }

产生:

{
  "data": {
    "entry": {
      "id": 26,
      "contentBlock": [
        {
          "__typename": "ContentBlockTheBasics",
          "id": "112",
          "theBasicsName": "Some name",
          "theBasicsIndustries": [
            {
              "id": 108,
              "title": "Hospitality"
            },
            {
              "id": 109,
              "title": "Technology"
            }
          ]
        }
      ]
    }
  }
}

但是,当我通过 API 运行相同的确切查询时,它会返回

无法查询类型“ContentBlockTheBasics”的字段“theBasicsIndustries”。

  1. 是否有特殊的查询标签?我尝试通过 Postman 运行相同的查询,但出现了相同的错误。
  2. 为什么它在管理控制台中起作用,而不是在 API 中?

谢谢!

标签: graphqlcraftcms

解决方案


这很愚蠢,但问题是由于 CraftQL 设置中缺少权限引起的!

我使用的令牌没有Query any tag访问权限。

在此处输入图像描述


推荐阅读