【问题标题】:Field 'translatableResources' doesn't exist on type 'QueryRoot'“QueryRoot”类型上不存在字段“translatableResources”
【发布时间】:2020-01-02 11:03:03
【问题描述】:

我在我的 Shopify 商店中安装了 Shopify GraphiQL App 来测试一些 GraphQL 查询。

我想通过他们的 API 翻译内容。 这是它的文档:https://help.shopify.com/en/api/guides/multi-language/translating-content-api#retrieve-a-list-of-translatable-resource-types

现在,我想查询他们在文档中的第一个示例:Retrieve a list of translatable resource types

{
  __type(name: "TranslatableResourceType") {
    enumValues {
      name
    }
  }
}

并收到此回复:

{
  "data": {
    "__type": null
  }
}

第二个查询也不起作用:Retrieve a list of translatable resources by their type

{
  translatableResources(first: 1, resourceType: PRODUCT) {
    edges {
      node {
        resourceId
        translatableContent {
          key
          value
          digest
          locale
        }
      }
    }
  }
}

第二次查询的错误:

{
  "errors": [
    {
      "message": "Field 'translatableResources' doesn't exist on type 'QueryRoot'",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "query",
        "translatableResources"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "QueryRoot",
        "fieldName": "translatableResources"
      }
    }
  ]
}

当我安装 Shopify GraphiQL 应用程序时,我选择了所有权限(包括 read_translationswrite_translations 权限)。 而且我的商店里确实有产品。

缺少哪个设置或我做错了什么?

【问题讨论】:

  • 好的,你必须选择unstable API 版本。现在可以执行查询了。

标签: graphql shopify


【解决方案1】:

我认为您使用的是 2019-07 或 2019-10,您需要使用不稳定的版本,其中 shopify 添加了 translatableResources Queryroot。请查看下图:

【讨论】:

  • 这确实是解决办法!感谢您的帮助!
  • 很高兴为您提供帮助:)
【解决方案2】:

如果您使用 POSTMAN 或 INSOMNIA 进行测试,那么 URL 将是:

https://{{store}}.myshopify.com/admin/api/unstable/graphql.json

在使用unstable版本前,需要将私服版本改为Unstable。

【讨论】:

    猜你喜欢
    • 2020-06-13
    • 2019-03-06
    • 2020-12-04
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    • 2021-11-27
    • 2017-09-23
    • 2017-07-13
    相关资源
    最近更新 更多